-
Notifications
You must be signed in to change notification settings - Fork 668
feat(skill): add draft confirmation card with view/install/discard #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Plan | ||
|
|
||
| ## Approach | ||
|
|
||
| 1. Extend skill presenter with draft action helpers that can read, install, and delete a draft by conversation id and draft id. | ||
| 2. When `skill_manage` `create` succeeds, include structured metadata in the tool raw result. | ||
| 3. In agent runtime dispatch, detect successful draft creation and append a synthetic `question_request` action block using the existing question interaction flow. | ||
| 4. Handle the synthetic interaction in `respondToolInteraction`: | ||
| - View: read draft content and keep the same card pending with content attached. | ||
| - Install: install draft folder into the configured skills directory, resolve the card, and update the `skill_manage` tool response. | ||
| - Discard: delete draft, resolve the card, and update the `skill_manage` tool response. | ||
| 5. Update renderer question panel to render draft preview content and localized option labels. | ||
| 6. Add/update tests for presenter draft actions, tool metadata, runtime interaction behavior, and renderer panel display. | ||
|
|
||
| ## Affected Interfaces | ||
|
|
||
| - `SkillManageResult` gains optional `draftStatus` and supporting metadata only where useful. | ||
| - `ISkillPresenter` gains draft action methods scoped by conversation id/draft id. | ||
| - `MCPToolResponse.toolResult` carries structured draft result metadata for runtime-only detection. | ||
| - Question action block `extra` gains skill-draft-specific metadata fields. | ||
|
|
||
| ## Data Flow | ||
|
|
||
| ```text | ||
| Agent skill_manage create | ||
| -> SkillPresenter.manageDraftSkill creates temp draft | ||
| -> AgentToolManager returns rawData.toolResult | ||
| -> dispatch detects draft metadata | ||
| -> append question_request card | ||
| -> renderer shows ChatToolInteractionOverlay | ||
| -> user chooses option | ||
| -> AgentRuntimePresenter handles draft action | ||
| -> SkillPresenter view/install/delete draft | ||
| -> update card/tool response and resume as needed | ||
| ``` | ||
|
|
||
| ## Compatibility | ||
|
|
||
| Existing question and permission blocks remain unchanged. Draft-specific behavior is guarded by `extra.skillDraftAction === 'confirm'` and the `skill_manage` tool name. | ||
|
|
||
| ## Test Strategy | ||
|
|
||
| - Unit test draft action helpers in `skillPresenter`. | ||
| - Unit test `AgentToolManager` raw metadata for `skill_manage create`. | ||
| - Unit/integration test runtime draft confirmation interactions. | ||
| - Renderer component test for draft preview rendering in `ChatToolInteractionOverlay`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Skill Draft Confirmation Card | ||
|
|
||
| ## User Need | ||
|
|
||
| When the Agent creates a reusable skill draft after a task, users need an obvious in-chat confirmation card instead of having the draft disappear into a temp directory with no visible follow-up path. | ||
|
|
||
| ## Goal | ||
|
|
||
| After a successful `skill_manage` draft creation, show a blocking question-style card in the chat: | ||
|
|
||
| - “已生成 skill draft:xxx” | ||
| - Options: 查看内容 / 安装为 Skill / 丢弃 | ||
|
|
||
| The card should reuse the existing question interaction panel so it fits the current Agent interaction flow and pauses until the user chooses an action. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| 1. A successful `skill_manage` `create` result produces an in-chat question interaction card before the Agent continues. | ||
| 2. The card has three options: view content, install as Skill, discard. | ||
| 3. Choosing “查看内容” shows the draft `SKILL.md` content and keeps the draft available for a later install/discard choice. | ||
| 4. Choosing “安装为 Skill” installs the draft into the configured skills directory and resumes the Agent with a clear success/failure tool result. | ||
| 5. Choosing “丢弃” deletes the draft and resumes the Agent with a clear result. | ||
| 6. Existing `deepchat_question` interactions continue to work unchanged. | ||
| 7. Draft install/delete operations remain scoped to the current conversation and opaque draft id. | ||
|
|
||
| ## Constraints | ||
|
|
||
| - Follow existing presenter boundaries and typed route/contracts patterns where needed. | ||
| - Keep the UI change focused by reusing `ChatToolInteractionOverlay` and `question_request` blocks. | ||
| - Avoid exposing absolute temp paths to the renderer or the model. | ||
| - All user-facing strings must use i18n keys. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - No full Drafts management list/page in Settings. | ||
| - No long-term draft persistence beyond the current temp draft retention policy. | ||
| - No automatic install without user confirmation. | ||
|
|
||
| ## Open Questions | ||
|
|
||
| Resolved: Use the existing question panel and show a confirmation card immediately after draft creation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Tasks | ||
|
|
||
| - [x] Add draft view/install/delete helpers to SkillPresenter. | ||
| - [x] Add structured draft metadata to skill_manage tool results. | ||
| - [x] Append synthetic draft confirmation question after successful draft create. | ||
| - [x] Handle view/install/discard responses in AgentRuntimePresenter. | ||
| - [x] Render draft preview content in question panel. | ||
| - [x] Add i18n strings. | ||
| - [x] Add/update tests. | ||
| - [ ] Run pnpm run format, pnpm run i18n, pnpm run lint. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only accept draft prompts from the expected tool origin.
This trusts any tool result that happens to expose
toolResult.skillDraft, then turns it into a privileged local draft action flow. A buggy or untrusted MCP tool can spoof this shape and surfaceview/install/discardagainst an arbitrary draft id. Gate the extraction on the executed tool name/source before enqueueing the question.Suggested fix
Also applies to: 1058-1058
🤖 Prompt for AI Agents