Compare commits
8 Commits
9118ebd662
...
fa55e32153
| Author | SHA1 | Date | |
|---|---|---|---|
| fa55e32153 | |||
| f6b1f5c45a | |||
| 1f9a1822c9 | |||
| 63015c6bbc | |||
| 24b30df992 | |||
| 67b1003831 | |||
| 00d37bdaf0 | |||
| c5fcb1427e |
@ -16,6 +16,10 @@ out/test/**
|
|||||||
# 依赖
|
# 依赖
|
||||||
node_modules/**
|
node_modules/**
|
||||||
|
|
||||||
|
# 文档(避免中文文件名打包问题)
|
||||||
|
docs/**
|
||||||
|
PUBLISH.md
|
||||||
|
|
||||||
# 只排除 waveform_trace 的 src/dist 目录
|
# 只排除 waveform_trace 的 src/dist 目录
|
||||||
tools/waveform_trace/src/dist/**
|
tools/waveform_trace/src/dist/**
|
||||||
|
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
所有重要的项目变更都将记录在此文件中。
|
所有重要的项目变更都将记录在此文件中。
|
||||||
|
|
||||||
|
## [1.0.9] - 2026-03-04
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 将工具折叠图标颜色从蓝色改为灰色
|
||||||
|
- 统一使用蓝色主题色
|
||||||
|
- 优化打包配置,排除重复的 exe 文件
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复代码变更继续对话查找不到之前的代码变更信息的 bug
|
||||||
|
- 修复对话展示两遍的问题
|
||||||
|
|
||||||
## [1.0.8] - 2026-03-03
|
## [1.0.8] - 2026-03-03
|
||||||
|
|
||||||
### 新增
|
### 新增
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "iccoder",
|
"name": "iccoder",
|
||||||
"displayName": "IC Coder: Agentic Verilog Platform",
|
"displayName": "IC Coder: Agentic Verilog Platform",
|
||||||
"description": "Agentic Verilog Coding Platform for Real-World FPGAs",
|
"description": "Agentic Verilog Coding Platform for Real-World FPGAs",
|
||||||
"version": "1.0.8",
|
"version": "1.0.11",
|
||||||
"publisher": "ICCoderAgenticVerilogPlatform",
|
"publisher": "ICCoderAgenticVerilogPlatform",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.80.0"
|
"vscode": "^1.80.0"
|
||||||
@ -135,6 +135,7 @@
|
|||||||
"@vscode/test-cli": "^0.0.12",
|
"@vscode/test-cli": "^0.0.12",
|
||||||
"@vscode/test-electron": "^2.5.2",
|
"@vscode/test-electron": "^2.5.2",
|
||||||
"@vscode/vsce": "^3.7.1",
|
"@vscode/vsce": "^3.7.1",
|
||||||
|
"copy-webpack-plugin": "^14.0.0",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"ts-loader": "^9.5.4",
|
"ts-loader": "^9.5.4",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
|
|||||||
24
pnpm-lock.yaml
generated
24
pnpm-lock.yaml
generated
@ -57,6 +57,9 @@ importers:
|
|||||||
'@vscode/vsce':
|
'@vscode/vsce':
|
||||||
specifier: ^3.7.1
|
specifier: ^3.7.1
|
||||||
version: 3.7.1
|
version: 3.7.1
|
||||||
|
copy-webpack-plugin:
|
||||||
|
specifier: ^14.0.0
|
||||||
|
version: 14.0.0(webpack@5.103.0)
|
||||||
eslint:
|
eslint:
|
||||||
specifier: ^9.39.1
|
specifier: ^9.39.1
|
||||||
version: 9.39.1
|
version: 9.39.1
|
||||||
@ -823,6 +826,12 @@ packages:
|
|||||||
convert-source-map@2.0.0:
|
convert-source-map@2.0.0:
|
||||||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||||
|
|
||||||
|
copy-webpack-plugin@14.0.0:
|
||||||
|
resolution: {integrity: sha512-3JLW90aBGeaTLpM7mYQKpnVdgsUZRExY55giiZgLuX/xTQRUs1dOCwbBnWnvY6Q6rfZoXMNwzOQJCSZPppfqXA==}
|
||||||
|
engines: {node: '>= 20.9.0'}
|
||||||
|
peerDependencies:
|
||||||
|
webpack: ^5.1.0
|
||||||
|
|
||||||
core-util-is@1.0.3:
|
core-util-is@1.0.3:
|
||||||
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
|
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
|
||||||
|
|
||||||
@ -1928,6 +1937,10 @@ packages:
|
|||||||
serialize-javascript@6.0.2:
|
serialize-javascript@6.0.2:
|
||||||
resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==}
|
resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==}
|
||||||
|
|
||||||
|
serialize-javascript@7.0.4:
|
||||||
|
resolution: {integrity: sha512-DuGdB+Po43Q5Jxwpzt1lhyFSYKryqoNjQSA9M92tyw0lyHIOur+XCalOUe0KTJpyqzT8+fQ5A0Jf7vCx/NKmIg==}
|
||||||
|
engines: {node: '>=20.0.0'}
|
||||||
|
|
||||||
setimmediate@1.0.5:
|
setimmediate@1.0.5:
|
||||||
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
|
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
|
||||||
|
|
||||||
@ -3297,6 +3310,15 @@ snapshots:
|
|||||||
|
|
||||||
convert-source-map@2.0.0: {}
|
convert-source-map@2.0.0: {}
|
||||||
|
|
||||||
|
copy-webpack-plugin@14.0.0(webpack@5.103.0):
|
||||||
|
dependencies:
|
||||||
|
glob-parent: 6.0.2
|
||||||
|
normalize-path: 3.0.0
|
||||||
|
schema-utils: 4.3.3
|
||||||
|
serialize-javascript: 7.0.4
|
||||||
|
tinyglobby: 0.2.15
|
||||||
|
webpack: 5.103.0(webpack-cli@6.0.1)
|
||||||
|
|
||||||
core-util-is@1.0.3: {}
|
core-util-is@1.0.3: {}
|
||||||
|
|
||||||
cross-spawn@7.0.6:
|
cross-spawn@7.0.6:
|
||||||
@ -4431,6 +4453,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
randombytes: 2.1.0
|
randombytes: 2.1.0
|
||||||
|
|
||||||
|
serialize-javascript@7.0.4: {}
|
||||||
|
|
||||||
setimmediate@1.0.5: {}
|
setimmediate@1.0.5: {}
|
||||||
|
|
||||||
shallow-clone@3.0.1:
|
shallow-clone@3.0.1:
|
||||||
|
|||||||
@ -53,7 +53,7 @@ function getTierIconUri(
|
|||||||
const iconUri = webview.asWebviewUri(
|
const iconUri = webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"titleIcon",
|
"titleIcon",
|
||||||
iconFile,
|
iconFile,
|
||||||
@ -138,7 +138,7 @@ export async function showICHelperPanel(
|
|||||||
retainContextWhenHidden: true,
|
retainContextWhenHidden: true,
|
||||||
localResourceRoots: [
|
localResourceRoots: [
|
||||||
vscode.Uri.joinPath(context.extensionUri, "media"),
|
vscode.Uri.joinPath(context.extensionUri, "media"),
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets"),
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -166,7 +166,7 @@ export async function showICHelperPanel(
|
|||||||
const autoIconUri = panel.webview.asWebviewUri(
|
const autoIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"model",
|
"model",
|
||||||
"Auto.png",
|
"Auto.png",
|
||||||
@ -175,7 +175,7 @@ export async function showICHelperPanel(
|
|||||||
const liteIconUri = panel.webview.asWebviewUri(
|
const liteIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"model",
|
"model",
|
||||||
"lite.png",
|
"lite.png",
|
||||||
@ -184,7 +184,7 @@ export async function showICHelperPanel(
|
|||||||
const syIconUri = panel.webview.asWebviewUri(
|
const syIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"model",
|
"model",
|
||||||
"Sy.png",
|
"Sy.png",
|
||||||
@ -193,7 +193,7 @@ export async function showICHelperPanel(
|
|||||||
const maxIconUri = panel.webview.asWebviewUri(
|
const maxIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"model",
|
"model",
|
||||||
"Max.png",
|
"Max.png",
|
||||||
@ -204,7 +204,7 @@ export async function showICHelperPanel(
|
|||||||
const qrCodeUri = panel.webview.asWebviewUri(
|
const qrCodeUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(
|
vscode.Uri.joinPath(
|
||||||
context.extensionUri,
|
context.extensionUri,
|
||||||
"src",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"QRCode",
|
"QRCode",
|
||||||
"wx.png",
|
"wx.png",
|
||||||
@ -436,6 +436,7 @@ export async function showICHelperPanel(
|
|||||||
message.askId,
|
message.askId,
|
||||||
message.selected,
|
message.selected,
|
||||||
message.customInput,
|
message.customInput,
|
||||||
|
message.answers
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
// 新增:中止对话
|
// 新增:中止对话
|
||||||
|
|||||||
@ -43,8 +43,7 @@ export interface MessageSegment {
|
|||||||
toolResult?: string;
|
toolResult?: string;
|
||||||
toolDescription?: string;
|
toolDescription?: string;
|
||||||
askId?: string;
|
askId?: string;
|
||||||
question?: string;
|
questions?: import("../types/api").QuestionItem[];
|
||||||
options?: string[];
|
|
||||||
// 智能体相关字段
|
// 智能体相关字段
|
||||||
agentId?: string;
|
agentId?: string;
|
||||||
agentName?: string;
|
agentName?: string;
|
||||||
@ -97,7 +96,7 @@ export interface DialogCallbacks {
|
|||||||
summary: string
|
summary: string
|
||||||
) => void;
|
) => void;
|
||||||
/** 显示问题(ask_user) */
|
/** 显示问题(ask_user) */
|
||||||
onQuestion?: (askId: string, question: string, options: string[]) => void;
|
onQuestion?: (askId: string, questions: import("../types/api").QuestionItem[]) => void;
|
||||||
/** 实时更新段落(流式过程中) */
|
/** 实时更新段落(流式过程中) */
|
||||||
onSegmentUpdate?: (segments: MessageSegment[]) => void;
|
onSegmentUpdate?: (segments: MessageSegment[]) => void;
|
||||||
/** 对话完成,返回所有段落 */
|
/** 对话完成,返回所有段落 */
|
||||||
@ -647,8 +646,11 @@ export class DialogSession {
|
|||||||
this.segments.push({
|
this.segments.push({
|
||||||
type: "question",
|
type: "question",
|
||||||
askId: askId,
|
askId: askId,
|
||||||
question: question,
|
questions: [{
|
||||||
options: ["确认执行", "取消"],
|
question: question,
|
||||||
|
options: ["确认执行", "取消"],
|
||||||
|
multiSelect: false
|
||||||
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 实时发送段落更新
|
// 实时发送段落更新
|
||||||
@ -666,8 +668,11 @@ export class DialogSession {
|
|||||||
await userInteractionManager.handleAskUser(
|
await userInteractionManager.handleAskUser(
|
||||||
{
|
{
|
||||||
askId: askId,
|
askId: askId,
|
||||||
question: question,
|
questions: [{
|
||||||
options: ["确认执行", "取消"],
|
question: question,
|
||||||
|
options: ["确认执行", "取消"],
|
||||||
|
multiSelect: false
|
||||||
|
}]
|
||||||
} as AskUserEvent,
|
} as AskUserEvent,
|
||||||
this.taskId
|
this.taskId
|
||||||
);
|
);
|
||||||
@ -714,8 +719,11 @@ export class DialogSession {
|
|||||||
// 注册问题到前端(类似 askUser),以便用户回答时能找到
|
// 注册问题到前端(类似 askUser),以便用户回答时能找到
|
||||||
const planEvent = {
|
const planEvent = {
|
||||||
askId: askId,
|
askId: askId,
|
||||||
question: `请确认执行计划:${data.title}`,
|
questions: [{
|
||||||
options: ["确认执行", "修改计划", "取消"],
|
question: `请确认执行计划:${data.title}`,
|
||||||
|
options: ["确认执行", "修改计划", "取消"],
|
||||||
|
multiSelect: false
|
||||||
|
}]
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await userInteractionManager.handleAskUser(
|
await userInteractionManager.handleAskUser(
|
||||||
@ -856,13 +864,12 @@ export class DialogSession {
|
|||||||
this.segments.push({
|
this.segments.push({
|
||||||
type: "question",
|
type: "question",
|
||||||
askId: data.askId,
|
askId: data.askId,
|
||||||
question: data.question,
|
questions: data.questions,
|
||||||
options: data.options,
|
|
||||||
});
|
});
|
||||||
// 实时发送段落更新(包含问题)
|
// 实时发送段落更新(包含问题)
|
||||||
callbacks.onSegmentUpdate?.(this.segments);
|
callbacks.onSegmentUpdate?.(this.segments);
|
||||||
// 同时调用 onQuestion 用于更新状态栏等
|
// 同时调用 onQuestion 用于更新状态栏等
|
||||||
callbacks.onQuestion?.(data.askId, data.question, data.options);
|
callbacks.onQuestion?.(data.askId, data.questions);
|
||||||
try {
|
try {
|
||||||
await userInteractionManager.handleAskUser(data, this.taskId);
|
await userInteractionManager.handleAskUser(data, this.taskId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1110,7 +1117,8 @@ export class DialogSession {
|
|||||||
async submitAnswer(
|
async submitAnswer(
|
||||||
askId: string,
|
askId: string,
|
||||||
selected?: string[],
|
selected?: string[],
|
||||||
customInput?: string
|
customInput?: string,
|
||||||
|
answers?: { [questionIndex: string]: string[] }
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// 直接调用 receiveAnswer,传递 taskId 作为 fallbackTaskId
|
// 直接调用 receiveAnswer,传递 taskId 作为 fallbackTaskId
|
||||||
// 如果 pendingQuestions 中有问题,走正常流程
|
// 如果 pendingQuestions 中有问题,走正常流程
|
||||||
@ -1119,6 +1127,7 @@ export class DialogSession {
|
|||||||
askId,
|
askId,
|
||||||
selected,
|
selected,
|
||||||
customInput,
|
customInput,
|
||||||
|
answers,
|
||||||
this.taskId
|
this.taskId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { submitAnswer, submitToolConfirm } from './apiClient';
|
import { submitAnswer, submitToolConfirm } from './apiClient';
|
||||||
import type { AskUserEvent, AnswerRequest } from '../types/api';
|
import type { AskUserEvent, AnswerRequest, QuestionItem } from '../types/api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 待处理的用户问题
|
* 待处理的用户问题
|
||||||
@ -12,8 +12,7 @@ import type { AskUserEvent, AnswerRequest } from '../types/api';
|
|||||||
interface PendingQuestion {
|
interface PendingQuestion {
|
||||||
askId: string;
|
askId: string;
|
||||||
taskId: string;
|
taskId: string;
|
||||||
question: string;
|
questions: QuestionItem[];
|
||||||
options: string[];
|
|
||||||
resolve: (answer: string) => void;
|
resolve: (answer: string) => void;
|
||||||
reject: (error: Error) => void;
|
reject: (error: Error) => void;
|
||||||
}
|
}
|
||||||
@ -45,9 +44,9 @@ export class UserInteractionManager {
|
|||||||
* @param taskId 当前任务ID
|
* @param taskId 当前任务ID
|
||||||
*/
|
*/
|
||||||
async handleAskUser(event: AskUserEvent, taskId: string): Promise<void> {
|
async handleAskUser(event: AskUserEvent, taskId: string): Promise<void> {
|
||||||
const { askId, question, options } = event;
|
const { askId, questions } = event;
|
||||||
|
|
||||||
console.log(`[UserInteraction] 收到问题: askId=${askId}, question=${question}`);
|
console.log(`[UserInteraction] 收到问题: askId=${askId}, count=${questions.length}`);
|
||||||
|
|
||||||
// 注意:问题显示已经通过 dialogService 的 onSegmentUpdate 统一处理
|
// 注意:问题显示已经通过 dialogService 的 onSegmentUpdate 统一处理
|
||||||
// 这里不再单独发送 showQuestion 命令,避免重复显示
|
// 这里不再单独发送 showQuestion 命令,避免重复显示
|
||||||
@ -57,8 +56,7 @@ export class UserInteractionManager {
|
|||||||
this.pendingQuestions.set(askId, {
|
this.pendingQuestions.set(askId, {
|
||||||
askId,
|
askId,
|
||||||
taskId,
|
taskId,
|
||||||
question,
|
questions,
|
||||||
options,
|
|
||||||
resolve: (answer: string) => {
|
resolve: (answer: string) => {
|
||||||
this.submitUserAnswer(askId, taskId, answer)
|
this.submitUserAnswer(askId, taskId, answer)
|
||||||
.then(() => resolve())
|
.then(() => resolve())
|
||||||
@ -80,24 +78,38 @@ export class UserInteractionManager {
|
|||||||
/**
|
/**
|
||||||
* 处理用户提交的回答(从 WebView 调用)
|
* 处理用户提交的回答(从 WebView 调用)
|
||||||
* @param askId 问题ID
|
* @param askId 问题ID
|
||||||
* @param selected 选中的选项
|
* @param selected 选中的选项(旧格式)
|
||||||
* @param customInput 自定义输入
|
* @param customInput 自定义输入(旧格式)
|
||||||
|
* @param answers 新格式:按问题索引的答案
|
||||||
* @param fallbackTaskId 当问题不存在时使用的 taskId(用于直接发送到后端)
|
* @param fallbackTaskId 当问题不存在时使用的 taskId(用于直接发送到后端)
|
||||||
*/
|
*/
|
||||||
async receiveAnswer(
|
async receiveAnswer(
|
||||||
askId: string,
|
askId: string,
|
||||||
selected?: string[],
|
selected?: string[],
|
||||||
customInput?: string,
|
customInput?: string,
|
||||||
|
answers?: { [questionIndex: string]: string[] },
|
||||||
fallbackTaskId?: string
|
fallbackTaskId?: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const pending = this.pendingQuestions.get(askId);
|
const pending = this.pendingQuestions.get(askId);
|
||||||
const answer = customInput || selected?.join(', ') || '';
|
|
||||||
|
// 构建答案字符串
|
||||||
|
let answer = '';
|
||||||
|
if (answers && Object.keys(answers).length > 0) {
|
||||||
|
// 新格式:多问题答案
|
||||||
|
answer = Object.entries(answers)
|
||||||
|
.sort(([a], [b]) => parseInt(a) - parseInt(b))
|
||||||
|
.map(([_, vals]) => vals.join('; '))
|
||||||
|
.join(' | ');
|
||||||
|
} else {
|
||||||
|
// 旧格式:单问题答案
|
||||||
|
answer = customInput || selected?.join(', ') || '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!pending) {
|
if (!pending) {
|
||||||
// 问题不存在(可能是页面刷新或会话切换后),尝试直接发送到后端
|
// 问题不存在(可能是页面刷新或会话切换后),尝试直接发送到后端
|
||||||
if (fallbackTaskId) {
|
if (fallbackTaskId) {
|
||||||
console.log(`[UserInteraction] 问题不在 pendingQuestions 中,直接发送到后端: askId=${askId}, taskId=${fallbackTaskId}`);
|
console.log(`[UserInteraction] 问题不在 pendingQuestions 中,直接发送到后端: askId=${askId}, taskId=${fallbackTaskId}`);
|
||||||
await this.submitUserAnswer(askId, fallbackTaskId, answer);
|
await this.submitUserAnswer(askId, fallbackTaskId, answer, answers);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`[UserInteraction] 问题不存在且无 fallbackTaskId: askId=${askId}`);
|
console.warn(`[UserInteraction] 问题不存在且无 fallbackTaskId: askId=${askId}`);
|
||||||
}
|
}
|
||||||
@ -119,7 +131,8 @@ export class UserInteractionManager {
|
|||||||
private async submitUserAnswer(
|
private async submitUserAnswer(
|
||||||
askId: string,
|
askId: string,
|
||||||
taskId: string,
|
taskId: string,
|
||||||
answer: string
|
answer: string,
|
||||||
|
answers?: { [questionIndex: string]: string[] }
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// 检查是否是工具确认类型的问题
|
// 检查是否是工具确认类型的问题
|
||||||
if (askId.startsWith('tool_confirm_')) {
|
if (askId.startsWith('tool_confirm_')) {
|
||||||
@ -148,7 +161,8 @@ export class UserInteractionManager {
|
|||||||
const request: AnswerRequest = {
|
const request: AnswerRequest = {
|
||||||
askId,
|
askId,
|
||||||
taskId,
|
taskId,
|
||||||
customInput: answer
|
answers: answers,
|
||||||
|
customInput: answers ? undefined : answer
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -194,11 +194,17 @@ export interface PlanSummaryUpdateEvent {
|
|||||||
timestamp: number;
|
timestamp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 单个问题项 */
|
||||||
|
export interface QuestionItem {
|
||||||
|
question: string;
|
||||||
|
options: string[];
|
||||||
|
multiSelect?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/** ask_user 事件数据 */
|
/** ask_user 事件数据 */
|
||||||
export interface AskUserEvent {
|
export interface AskUserEvent {
|
||||||
askId: string;
|
askId: string;
|
||||||
question: string;
|
questions: QuestionItem[];
|
||||||
options: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** complete 事件数据 */
|
/** complete 事件数据 */
|
||||||
@ -351,10 +357,12 @@ export interface AnswerRequest {
|
|||||||
askId: string;
|
askId: string;
|
||||||
/** 任务ID */
|
/** 任务ID */
|
||||||
taskId: string;
|
taskId: string;
|
||||||
/** 选中的选项列表 */
|
/** 选中的选项列表(旧格式,兼容) */
|
||||||
selected?: string[];
|
selected?: string[];
|
||||||
/** 自定义输入内容 */
|
/** 自定义输入内容(旧格式,兼容) */
|
||||||
customInput?: string;
|
customInput?: string;
|
||||||
|
/** 新格式:按问题索引的答案 */
|
||||||
|
answers?: { [questionIndex: string]: string[] };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用户回答响应 */
|
/** 用户回答响应 */
|
||||||
|
|||||||
@ -469,10 +469,11 @@ async function handleUserMessageWithBackend(
|
|||||||
export async function handleUserAnswer(
|
export async function handleUserAnswer(
|
||||||
askId: string,
|
askId: string,
|
||||||
selected?: string[],
|
selected?: string[],
|
||||||
customInput?: string
|
customInput?: string,
|
||||||
|
answers?: { [questionIndex: string]: string[] }
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (currentSession) {
|
if (currentSession) {
|
||||||
await currentSession.submitAnswer(askId, selected, customInput);
|
await currentSession.submitAnswer(askId, selected, customInput, answers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export function showICHelperPanel(context: vscode.ExtensionContext) {
|
|||||||
retainContextWhenHidden: true,
|
retainContextWhenHidden: true,
|
||||||
localResourceRoots: [
|
localResourceRoots: [
|
||||||
vscode.Uri.joinPath(context.extensionUri, "media"),
|
vscode.Uri.joinPath(context.extensionUri, "media"),
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets")
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -47,21 +47,21 @@ export function showICHelperPanel(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// 获取模型图标URI
|
// 获取模型图标URI
|
||||||
const autoIconUri = panel.webview.asWebviewUri(
|
const autoIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets", "model", "Auto.png")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets", "model", "Auto.png")
|
||||||
);
|
);
|
||||||
const liteIconUri = panel.webview.asWebviewUri(
|
const liteIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets", "model", "lite.png")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets", "model", "lite.png")
|
||||||
);
|
);
|
||||||
const syIconUri = panel.webview.asWebviewUri(
|
const syIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets", "model", "Sy.png")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets", "model", "Sy.png")
|
||||||
);
|
);
|
||||||
const maxIconUri = panel.webview.asWebviewUri(
|
const maxIconUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets", "model", "Max.png")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets", "model", "Max.png")
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取二维码图片URI
|
// 获取二维码图片URI
|
||||||
const qrCodeUri = panel.webview.asWebviewUri(
|
const qrCodeUri = panel.webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(context.extensionUri, "src", "assets", "QRCode", "wx.png")
|
vscode.Uri.joinPath(context.extensionUri, "dist", "assets", "QRCode", "wx.png")
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取Logo URI
|
// 获取Logo URI
|
||||||
@ -129,7 +129,8 @@ export function showICHelperPanel(context: vscode.ExtensionContext) {
|
|||||||
handleUserAnswer(
|
handleUserAnswer(
|
||||||
message.askId,
|
message.askId,
|
||||||
message.selected,
|
message.selected,
|
||||||
message.customInput
|
message.customInput,
|
||||||
|
message.answers
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
// 新增:中止对话
|
// 新增:中止对话
|
||||||
|
|||||||
@ -1188,64 +1188,60 @@ export function getMessageAreaScript(): string {
|
|||||||
} else if (segment.type === 'question') {
|
} else if (segment.type === 'question') {
|
||||||
segmentDiv.className += ' segment-question';
|
segmentDiv.className += ' segment-question';
|
||||||
|
|
||||||
|
// 兼容旧格式:如果有 segment.question,转换为 questions 数组
|
||||||
|
const questions = segment.questions || (segment.question ? [{
|
||||||
|
question: segment.question,
|
||||||
|
options: segment.options || [],
|
||||||
|
multiSelect: false
|
||||||
|
}] : []);
|
||||||
|
|
||||||
// 检查是否已回答
|
// 检查是否已回答
|
||||||
const isAnswered = answeredQuestions.has(segment.askId);
|
const isAnswered = answeredQuestions.has(segment.askId);
|
||||||
const selectedAnswer = answeredQuestions.get(segment.askId);
|
const savedAnswers = answeredQuestions.get(segment.askId) || {};
|
||||||
|
|
||||||
if (isAnswered) {
|
if (isAnswered) {
|
||||||
segmentDiv.classList.add('answered');
|
segmentDiv.classList.add('answered');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有选项
|
// 渲染多个问题
|
||||||
const hasOptions = segment.options && segment.options.length > 0;
|
const questionsHtml = questions.map((q, qIndex) => {
|
||||||
|
const inputType = q.multiSelect ? 'checkbox' : 'radio';
|
||||||
|
const inputName = \`q\${qIndex}\`;
|
||||||
|
const selectedAnswers = savedAnswers[qIndex] || [];
|
||||||
|
|
||||||
const optionsHtml = hasOptions
|
const optionsHtml = q.options.map(opt => {
|
||||||
? (segment.options || []).map(opt => {
|
const isSelected = selectedAnswers.includes(opt);
|
||||||
const isSelected = isAnswered && opt === selectedAnswer;
|
return \`<label style="display:flex;align-items:center;gap:6px;cursor:pointer;padding:4px 0;">
|
||||||
return \`<button class="question-option\${isSelected ? ' selected' : ''}" data-option="\${opt}">\${opt}</button>\`;
|
<input type="\${inputType}" name="\${inputName}" value="\${opt}" \${isSelected ? 'checked' : ''} \${isAnswered ? 'disabled' : ''}>
|
||||||
}).join('')
|
<span>\${opt}</span>
|
||||||
: '';
|
</label>\`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
return \`
|
||||||
|
<div class="question-item" data-question-index="\${qIndex}" style="margin-bottom:12px;">
|
||||||
|
<div class="question-text" style="margin-bottom:8px;">\${formatText(q.question)}</div>
|
||||||
|
<div class="question-options">\${optionsHtml}</div>
|
||||||
|
</div>
|
||||||
|
\`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
segmentDiv.innerHTML = \`
|
segmentDiv.innerHTML = \`
|
||||||
<div class="question-text">\${formatText(segment.question || '')}</div>
|
\${questionsHtml}
|
||||||
\${hasOptions ? \`<div class="question-options" data-ask-id="\${segment.askId}">\${optionsHtml}</div>\` : ''}
|
<button class="custom-submit" style="display:\${isAnswered ? 'none' : 'block'};margin-top:8px;padding:8px 16px;background:var(--vscode-button-background);color:var(--vscode-button-foreground);border:none;border-radius:6px;cursor:pointer;">提交答案</button>
|
||||||
<div class="custom-input-container" style="display: \${isAnswered ? 'none' : 'flex'};">
|
|
||||||
<input type="text" class="custom-input" placeholder="\${hasOptions ? '输入其他答案...' : '请输入您的答案...'}" />
|
|
||||||
<button class="custom-submit">提交</button>
|
|
||||||
</div>
|
|
||||||
\`;
|
\`;
|
||||||
|
|
||||||
// 只在未回答时添加事件监听
|
// 只在未回答时添加事件监听
|
||||||
if (!isAnswered) {
|
if (!isAnswered) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (hasOptions) {
|
|
||||||
const optionButtons = segmentDiv.querySelectorAll('.question-option');
|
|
||||||
optionButtons.forEach(btn => {
|
|
||||||
btn.addEventListener('click', function() {
|
|
||||||
const option = this.getAttribute('data-option');
|
|
||||||
handleQuestionAnswerInSegment(segment.askId, option, segmentDiv);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitBtn = segmentDiv.querySelector('.custom-submit');
|
const submitBtn = segmentDiv.querySelector('.custom-submit');
|
||||||
const customInput = segmentDiv.querySelector('.custom-input');
|
if (submitBtn) {
|
||||||
if (submitBtn && customInput) {
|
|
||||||
submitBtn.addEventListener('click', function() {
|
submitBtn.addEventListener('click', function() {
|
||||||
const customValue = customInput.value.trim();
|
const answers = {};
|
||||||
if (customValue) {
|
questions.forEach((q, qIndex) => {
|
||||||
handleQuestionAnswerInSegment(segment.askId, customValue, segmentDiv);
|
const inputs = segmentDiv.querySelectorAll(\`input[name="q\${qIndex}"]:checked\`);
|
||||||
}
|
answers[qIndex] = Array.from(inputs).map(input => input.value);
|
||||||
});
|
});
|
||||||
|
handleMultiQuestionAnswer(segment.askId, answers, segmentDiv);
|
||||||
// 支持回车提交
|
|
||||||
customInput.addEventListener('keypress', function(e) {
|
|
||||||
if (e.key === 'Enter') {
|
|
||||||
const customValue = customInput.value.trim();
|
|
||||||
if (customValue) {
|
|
||||||
handleQuestionAnswerInSegment(segment.askId, customValue, segmentDiv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -1723,6 +1719,34 @@ export function getMessageAreaScript(): string {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理多问题答案提交
|
||||||
|
function handleMultiQuestionAnswer(askId, answers, segmentDiv) {
|
||||||
|
console.log('[WebView] 多问题答案提交:', askId, answers);
|
||||||
|
|
||||||
|
// 保存答案到 Map 中
|
||||||
|
answeredQuestions.set(askId, answers);
|
||||||
|
|
||||||
|
// 标记问题已回答
|
||||||
|
segmentDiv.classList.add('answered');
|
||||||
|
|
||||||
|
// 禁用所有输入
|
||||||
|
const inputs = segmentDiv.querySelectorAll('input');
|
||||||
|
inputs.forEach(input => input.disabled = true);
|
||||||
|
|
||||||
|
// 隐藏提交按钮
|
||||||
|
const submitBtn = segmentDiv.querySelector('.custom-submit');
|
||||||
|
if (submitBtn) {
|
||||||
|
submitBtn.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送答案到后端
|
||||||
|
vscode.postMessage({
|
||||||
|
command: 'submitAnswer',
|
||||||
|
askId: askId,
|
||||||
|
answers: answers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
${getWaveformPreviewScript()}
|
${getWaveformPreviewScript()}
|
||||||
|
|
||||||
${getCodeHighlightScript()}
|
${getCodeHighlightScript()}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function getNdtWelcomeModalContent(logoUri?: string): string {
|
|||||||
|
|
||||||
<div class="ndt-welcome-modal-header">
|
<div class="ndt-welcome-modal-header">
|
||||||
<div class="ndt-welcome-icon">🎉</div>
|
<div class="ndt-welcome-icon">🎉</div>
|
||||||
<h2>欢迎宁德时代新能源科技股份有限公司<span style="white-space: nowrap;">的各位专家</span>使用 IC Coder!</h2>
|
<h2>欢迎企业<span style="white-space: nowrap;">的各位专家</span>使用 IC Coder!</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ndt-welcome-modal-body">
|
<div class="ndt-welcome-modal-body">
|
||||||
|
|||||||
@ -47,13 +47,6 @@ export function getWelcomeModalContent(logoUri?: string): string {
|
|||||||
|
|
||||||
<!-- 按钮组 -->
|
<!-- 按钮组 -->
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button id="tutorialBtn" class="welcome-btn welcome-btn-secondary">
|
|
||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
||||||
<path d="M8 2C4.7 2 2 4.7 2 8s2.7 6 6 6 6-2.7 6-6-2.7-6-6-6zm0 10c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z" fill="currentColor"/>
|
|
||||||
<path d="M8 5v3l2 2" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
<span>查看使用教程</span>
|
|
||||||
</button>
|
|
||||||
<button id="welcomeStartBtn" class="welcome-btn welcome-btn-primary">
|
<button id="welcomeStartBtn" class="welcome-btn welcome-btn-primary">
|
||||||
<span>开始使用</span>
|
<span>开始使用</span>
|
||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
||||||
@ -209,7 +202,6 @@ export function getWelcomeModalStyles(): string {
|
|||||||
/* 按钮组 */
|
/* 按钮组 */
|
||||||
.button-group {
|
.button-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.welcome-btn {
|
.welcome-btn {
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
|
|
||||||
//@ts-check
|
//@ts-check
|
||||||
/** @typedef {import('webpack').Configuration} WebpackConfig **/
|
/** @typedef {import('webpack').Configuration} WebpackConfig **/
|
||||||
@ -45,5 +46,12 @@ const extensionConfig = {
|
|||||||
infrastructureLogging: {
|
infrastructureLogging: {
|
||||||
level: "log", // enables logging required for problem matchers
|
level: "log", // enables logging required for problem matchers
|
||||||
},
|
},
|
||||||
|
plugins: [
|
||||||
|
new CopyWebpackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{ from: 'src/assets', to: 'assets' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
]
|
||||||
};
|
};
|
||||||
module.exports = [ extensionConfig ];
|
module.exports = [ extensionConfig ];
|
||||||
Reference in New Issue
Block a user