From 546eebd73fcb423b29b572bfff571f22724be206 Mon Sep 17 00:00:00 2001 From: Ethanlita Date: Fri, 26 Jun 2026 11:10:52 +0800 Subject: [PATCH 1/2] feat(editor): add Copilot in-editor code guides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of auto-applying patches or simply point to the editor area using a purple arrow, Copilot now guides the user to make the edit themselves in the editor, so children practice writing code by hand. A reply can render four guide elements(custom elements), each backed by an in-editor overlay: - [NEW] code-drag-hint — opens a drop target at a line and highlights the matching API reference item, for inserting a new statement by drag - [NEW] code-type-hint — opens a pre-indented blank line with a "Type the code here" chip and a green reference ghost, for typing a new statement - [NEW] code-delete-hint — highlights a range in red, for deleting it - [MODIFIED] code-change-hint — shows the deletion (red) and addition (green) at once, for replacing existing code (inline or whole-line) The CodeGuideController keeps a single active guide, navigates to it, and auto-dismisses it once the suggested edit is done (whitespace-insensitive). Completion for delete/change is region-local: an invisible Monaco decoration tracks the target range so it stays correct even when the user edits elsewhere. Shared logic lives in use-code-guide.ts (re-show on stream settle, reopen on click, skip-if-already-done, blank-line scaffolding) so all elements behave consistently. Changes to be committed: new file: node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json modified: spx-gui/src/components/copilot/CopilotRound.vue modified: spx-gui/src/components/copilot/context.ts modified: spx-gui/src/components/copilot/copilot.ts modified: spx-gui/src/components/editor/copilot/CodeChange.vue new file: spx-gui/src/components/editor/copilot/CodeDeleteHint.vue new file: spx-gui/src/components/editor/copilot/CodeDragHint.vue new file: spx-gui/src/components/editor/copilot/CodeTypeHint.vue modified: spx-gui/src/components/editor/copilot/index.ts new file: spx-gui/src/components/editor/copilot/use-code-guide.ts modified: spx-gui/src/components/xgo-code-editor/index.ts modified: spx-gui/src/components/xgo-code-editor/ui/CodeEditorUI.vue modified: spx-gui/src/components/xgo-code-editor/ui/api-reference/APIReferenceItem.vue modified: spx-gui/src/components/xgo-code-editor/ui/api-reference/index.ts modified: spx-gui/src/components/xgo-code-editor/ui/code-editor-ui.ts new file: spx-gui/src/components/xgo-code-editor/ui/code-guide/CodeGuideUI.vue new file: spx-gui/src/components/xgo-code-editor/ui/code-guide/index.test.ts new file: spx-gui/src/components/xgo-code-editor/ui/code-guide/index.ts modified: spx-gui/src/components/xgo-code-editor/ui/common.ts --- .../results.json | 1 + .../src/components/copilot/CopilotRound.vue | 4 + spx-gui/src/components/copilot/context.ts | 21 +- spx-gui/src/components/copilot/copilot.ts | 11 + .../components/editor/copilot/CodeChange.vue | 315 ++++++++++--- .../editor/copilot/CodeDeleteHint.vue | 111 +++++ .../editor/copilot/CodeDragHint.vue | 110 +++++ .../editor/copilot/CodeTypeHint.vue | 111 +++++ .../src/components/editor/copilot/index.ts | 42 +- .../editor/copilot/use-code-guide.ts | 207 +++++++++ .../src/components/xgo-code-editor/index.ts | 2 + .../xgo-code-editor/ui/CodeEditorUI.vue | 8 + .../ui/api-reference/APIReferenceItem.vue | 29 +- .../xgo-code-editor/ui/api-reference/index.ts | 47 +- .../xgo-code-editor/ui/code-editor-ui.ts | 26 ++ .../ui/code-guide/CodeGuideUI.vue | 428 ++++++++++++++++++ .../ui/code-guide/index.test.ts | 426 +++++++++++++++++ .../xgo-code-editor/ui/code-guide/index.ts | 291 ++++++++++++ .../components/xgo-code-editor/ui/common.ts | 45 ++ 19 files changed, 2159 insertions(+), 76 deletions(-) create mode 100644 node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json create mode 100644 spx-gui/src/components/editor/copilot/CodeDeleteHint.vue create mode 100644 spx-gui/src/components/editor/copilot/CodeDragHint.vue create mode 100644 spx-gui/src/components/editor/copilot/CodeTypeHint.vue create mode 100644 spx-gui/src/components/editor/copilot/use-code-guide.ts create mode 100644 spx-gui/src/components/xgo-code-editor/ui/code-guide/CodeGuideUI.vue create mode 100644 spx-gui/src/components/xgo-code-editor/ui/code-guide/index.test.ts create mode 100644 spx-gui/src/components/xgo-code-editor/ui/code-guide/index.ts diff --git a/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json new file mode 100644 index 0000000000..21c4bf8989 --- /dev/null +++ b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json @@ -0,0 +1 @@ +{"version":"4.1.9","results":[[":spx-gui/src/components/xgo-code-editor/ui/code-guide/index.test.ts",{"duration":0,"failed":true}]]} \ No newline at end of file diff --git a/spx-gui/src/components/copilot/CopilotRound.vue b/spx-gui/src/components/copilot/CopilotRound.vue index 58133e2f19..38bcc0cd17 100644 --- a/spx-gui/src/components/copilot/CopilotRound.vue +++ b/spx-gui/src/components/copilot/CopilotRound.vue @@ -1,6 +1,7 @@