From 4495d30fecb97010f4bbff596f8d5a929edebaa9 Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:10:48 +0100 Subject: [PATCH] The manifest says what the extension does: welcome texts, palette, menus and keys, settings wording An empty Journeys view now explains itself, the description names notes, journeys and the understanding check, inbox actions are in the palette, dead command contributions are gone, settings say what they do, and the menus and keys the other slices need are wired and pinned by manifest tests. --- package.json | 210 ++++++++++++++++++++++--------- scripts/keymap.mjs | 4 + src/notes/index.ts | 11 +- src/platform/commands.ts | 24 ++-- src/threads/index.ts | 8 +- test/integration/main/threads.ts | 4 +- test/keybindings.test.ts | 18 ++- test/manifest.test.ts | 150 +++++++++++++++++++++- 8 files changed, 340 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index dbe23e9..03819db 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-notes", "displayName": "Code Notes", - "description": "Notes on code that your coding agent answers in threads, and Code Journeys: guided, animated walks through how a codebase works.", + "description": "Understand code you did not write: notes your coding agent answers, journeys through how it works, and an understanding check before you merge.", "version": "0.26.0", "publisher": "tomeyer97", "license": "MIT", @@ -51,7 +51,10 @@ "skills/understanding-check/SKILL.md", "skills/understanding-check/scripts/questions.mjs", "cli/understanding.mjs", + "docs/agent-protocol.md", + "docs/journey-format.md", "docs/podcast-format.md", + "docs/understanding-check.md", "README.md", "CHANGELOG.md", "LICENSE" @@ -81,7 +84,8 @@ { "type": "webview", "id": "codeNotes.check", - "name": "Check" + "name": "Check", + "when": "!codeNotes.checkOnBase" }, { "id": "codeNotes.journeys", @@ -99,6 +103,10 @@ { "view": "codeNotes.notes", "contents": "Select code and press Ctrl+' C to leave a note.\n[Add a Note](command:codeNotes.add)" + }, + { + "view": "codeNotes.journeys", + "contents": "Ask how something works; Claude writes a walk through the code.\n[Ask a Question About the Code…](command:codeNotes.askQuestion)" } ], "commands": [ @@ -108,11 +116,6 @@ "category": "Code Notes", "icon": "$(comment)" }, - { - "command": "codeNotes.addQuick", - "title": "Add One-Line Note", - "category": "Code Notes" - }, { "command": "codeNotes.reply", "title": "Reply", @@ -120,7 +123,7 @@ }, { "command": "codeNotes.createFromThread", - "title": "Add Note", + "title": "Save Note", "category": "Code Notes" }, { @@ -247,11 +250,6 @@ "category": "Code Notes", "icon": "$(copy)" }, - { - "command": "codeNotes.replyResolve", - "title": "Reply & Resolve", - "category": "Code Notes" - }, { "command": "codeNotes.hideSession", "title": "Hide Session in Editor", @@ -266,7 +264,7 @@ }, { "command": "codeNotes.showOnlySession", - "title": "Show Only This Session", + "title": "Show Only This Session in Editor", "category": "Code Notes", "icon": "$(target)" }, @@ -353,7 +351,7 @@ }, { "command": "codeNotes.askQuestion", - "title": "Ask a Question About the Code…", + "title": "Find or Write a Journey…", "category": "Code Notes" }, { @@ -515,6 +513,26 @@ "title": "Act on a Concern Found During the Check", "category": "Code Notes" }, + { + "command": "codeNotes.concernFix", + "title": "Suggest a Fix", + "category": "Code Notes" + }, + { + "command": "codeNotes.concernTodo", + "title": "Add TODO", + "category": "Code Notes" + }, + { + "command": "codeNotes.concernFlag", + "title": "Flag for Reviewer", + "category": "Code Notes" + }, + { + "command": "codeNotes.concernDismiss", + "title": "Dismiss Concern", + "category": "Code Notes" + }, { "command": "codeNotes.pickJourneyStep", "title": "Pick a Journey Step Here", @@ -885,6 +903,16 @@ "command": "codeNotes.cancelMove", "key": "escape", "when": "codeNotes.moving && editorTextFocus && !suggestWidgetVisible && !findWidgetVisible" + }, + { + "command": "codeNotes.moveToSelection", + "key": "enter", + "when": "codeNotes.moving && editorTextFocus && !suggestWidgetVisible" + }, + { + "command": "codeNotes.closeNoteBox", + "key": "escape", + "when": "commentEditorFocused && commentController == codeNotes && commentThreadIsEmpty" } ], "menus": { @@ -919,18 +947,43 @@ "command": "codeNotes.answerCheck", "group": "inline@1", "when": "commentController == codeNotes && !commentThreadIsEmpty && commentThread =~ /check/" + }, + { + "command": "codeNotes.askClaude", + "when": "commentController == codeNotes && config.codeNotes.claude.mode != 'off' && commentThread =~ /open/ && !(commentThread =~ /check/) && !(commentThread =~ /asking/) && codeNotes.claudeFound", + "group": "inline@2" + }, + { + "command": "codeNotes.concernFix", + "when": "commentController == codeNotes && commentThread =~ /concern/", + "group": "inline@3" + }, + { + "command": "codeNotes.concernTodo", + "when": "commentController == codeNotes && commentThread =~ /concern/ && !(commentThread =~ /todo/)", + "group": "inline@4" + }, + { + "command": "codeNotes.concernFlag", + "when": "commentController == codeNotes && commentThread =~ /concern/", + "group": "inline@5" + }, + { + "command": "codeNotes.concernDismiss", + "when": "commentController == codeNotes && commentThread =~ /concern/", + "group": "inline@6" } ], "comments/commentThread/title": [ { "command": "codeNotes.cancelClaude", - "group": "navigation@0", + "group": "navigation@1", "when": "commentController == codeNotes && commentThread =~ /asking/" }, { "command": "codeNotes.askClaude", "group": "navigation@0", - "when": "commentController == codeNotes && config.codeNotes.claude.mode != 'off' && (commentThread =~ /open/ || commentThread =~ /check/) && !(commentThread =~ /asking/) && codeNotes.claudeFound" + "when": "commentController == codeNotes && config.codeNotes.claude.mode != 'off' && commentThread =~ /check/ && !(commentThread =~ /asking/) && codeNotes.claudeFound" }, { "command": "codeNotes.resolve", @@ -1018,6 +1071,16 @@ "command": "codeNotes.sortJourneys", "when": "view == codeNotes.journeys", "group": "navigation@2" + }, + { + "command": "codeNotes.refresh", + "when": "view == codeNotes.notes", + "group": "3_reload@1" + }, + { + "command": "codeNotes.tutorial", + "when": "view == codeNotes.journeys && codeNotes.hasJourneys", + "group": "1_help@1" } ], "view/item/context": [ @@ -1198,11 +1261,11 @@ }, { "command": "codeNotes.showResolved", - "when": "false" + "when": "codeNotes.hasNotes && !codeNotes.showResolved" }, { "command": "codeNotes.hideResolved", - "when": "false" + "when": "codeNotes.showResolved" }, { "command": "codeNotes.resolve", @@ -1232,10 +1295,6 @@ "command": "codeNotes.copyNotePrompt", "when": "codeNotes.cursorOnNote" }, - { - "command": "codeNotes.replyResolve", - "when": "false" - }, { "command": "codeNotes.openAt", "when": "false" @@ -1282,7 +1341,7 @@ }, { "command": "codeNotes.showAllSessions", - "when": "false" + "when": "codeNotes.hasHiddenSessions" }, { "command": "codeNotes.applySuggestion", @@ -1290,11 +1349,11 @@ }, { "command": "codeNotes.groupByFile", - "when": "false" + "when": "codeNotes.groupBy == 'session'" }, { "command": "codeNotes.groupBySession", - "when": "false" + "when": "codeNotes.groupBy == 'file' && codeNotes.hasSessions" }, { "command": "codeNotes.openJourney", @@ -1340,10 +1399,6 @@ "command": "codeNotes.tutorial", "when": "codeNotes.hasJourneys" }, - { - "command": "codeNotes.addQuick", - "when": "false" - }, { "command": "codeNotes.addPathNote", "when": "false" @@ -1370,27 +1425,27 @@ }, { "command": "codeNotes.markAllRead", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.resolveAll", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.deleteResolved", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.nextUnread", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.previousUnread", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.filter", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.find", @@ -1398,7 +1453,7 @@ }, { "command": "codeNotes.copyAgentPrompt", - "when": "false" + "when": "codeNotes.hasNotes" }, { "command": "codeNotes.resolveNext", @@ -1412,10 +1467,6 @@ "command": "codeNotes.askFromThread", "when": "false" }, - { - "command": "codeNotes.refresh", - "when": "false" - }, { "command": "codeNotes.toggleAuthorMode", "when": "config.codeNotes.journeys.authorMode" @@ -1439,6 +1490,38 @@ { "command": "codeNotes.journeysHereAll", "when": "false" + }, + { + "command": "codeNotes.refreshJourney", + "when": "codeNotes.hasJourneys" + }, + { + "command": "codeNotes.playPodcast", + "when": "codeNotes.hasJourneys" + }, + { + "command": "codeNotes.sortJourneys", + "when": "codeNotes.hasJourneys" + }, + { + "command": "codeNotes.toggleAnimation", + "when": "codeNotes.hasJourneys" + }, + { + "command": "codeNotes.concernFix", + "when": "false" + }, + { + "command": "codeNotes.concernTodo", + "when": "false" + }, + { + "command": "codeNotes.concernFlag", + "when": "false" + }, + { + "command": "codeNotes.concernDismiss", + "when": "false" } ], "explorer/context": [ @@ -1476,7 +1559,7 @@ "codeNotes.highlight": { "type": "boolean", "default": true, - "description": "Tint lines that have an open note." + "description": "Show a bar beside lines with an open note." }, "codeNotes.showResolvedInEditor": { "type": "boolean", @@ -1490,18 +1573,29 @@ "always", "off" ], + "enumItemLabels": [ + "When I ask", + "Every note", + "Never" + ], "default": "button", "enumDescriptions": [ "An \"Ask Claude\" button on the note box, threads and the list.", "Every new note and reply goes to Claude right away.", "No Claude." ], - "description": "Answer notes with Claude Code (the newest `claude` CLI found, your existing login). Claude can read the code but not change it (and can use the skills in Code Notes › Claude: Skills). Ask Claude shows only when the `claude` CLI is found (install Claude Code, or set Code Notes › Claude: Path)." + "description": "Claude Code answers notes. It can read code, never change it." }, "codeNotes.claude.model": { "type": "string", "default": "", - "description": "Model for answers (e.g. \"sonnet\" for cheaper, faster answers). Empty: Claude Code's default." + "examples": [ + "sonnet", + "opus", + "haiku", + "fable" + ], + "description": "Model for answers: sonnet, opus, haiku, fable or a model id. Empty: Claude Code's default." }, "codeNotes.claude.path": { "type": "string", @@ -1551,17 +1645,29 @@ "codeNotes.journeys.model": { "type": "string", "default": "", - "description": "Model Claude Code uses to write a journey from the journey picker (\"Ask the agent to write a journey…\"). Empty: Code Notes › Claude: Model, else Claude Code's default." + "examples": [ + "sonnet", + "opus", + "haiku", + "fable" + ], + "markdownDescription": "Model that writes journeys: sonnet, opus, haiku, fable or an id. Empty: `#codeNotes.claude.model#`." }, "codeNotes.understanding.background": { "type": "boolean", "default": true, - "markdownDescription": "Write a branch's understanding-check questions in the background when it is pushed without a check; the status bar says when they are ready." + "markdownDescription": "Writes the questions with Claude when a branch is pushed, in repositories that use the check." }, "codeNotes.understanding.model": { "type": "string", "default": "", - "markdownDescription": "The model that writes and grades the understanding-check questions (`sonnet`, `opus`, a `claude-*` id). Empty: **Code Notes › Claude: Model**, else Claude Code's default." + "examples": [ + "sonnet", + "opus", + "haiku", + "fable" + ], + "markdownDescription": "Model for the check: sonnet, opus, haiku, fable or an id. Empty: `#codeNotes.claude.model#`." } } }, @@ -1586,15 +1692,6 @@ "highContrastLight": "#00a39040" } }, - { - "id": "codeNotes.noteBackground", - "description": "Background of lines with an open note.", - "defaults": { - "dark": "#a371f726", - "light": "#8250df12", - "highContrast": "#a371f726" - } - }, { "id": "codeNotes.noteBorder", "description": "Left bar of lines with an open note.", @@ -1643,7 +1740,6 @@ ], "configurationDefaults": { "comments.openView": "never", - "comments.maxHeight": false, "editor.smoothScrolling": true } }, diff --git a/scripts/keymap.mjs b/scripts/keymap.mjs index 2483b56..c281076 100644 --- a/scripts/keymap.mjs +++ b/scripts/keymap.mjs @@ -28,6 +28,10 @@ export const PREFIXES = [{ key: 'ctrl+[IntlBackslash]', arg: '<' }, { key: "ctrl /** Bindings outside the chord scheme. */ export const OTHERS = [ { command: 'codeNotes.cancelMove', key: 'escape', when: 'codeNotes.moving && editorTextFocus && !suggestWidgetVisible && !findWidgetVisible' }, + // Moving a note: Enter puts it on the selected lines (the status bar item says so). + { command: 'codeNotes.moveToSelection', key: 'enter', when: 'codeNotes.moving && editorTextFocus && !suggestWidgetVisible' }, + // Esc in an empty new note box closes it and keeps the draft. + { command: 'codeNotes.closeNoteBox', key: 'escape', when: 'commentEditorFocused && commentController == codeNotes && commentThreadIsEmpty' }, ] /** diff --git a/src/notes/index.ts b/src/notes/index.ts index 4d99915..20c6e5c 100644 --- a/src/notes/index.ts +++ b/src/notes/index.ts @@ -43,9 +43,6 @@ export type { NotesFeaturePorts } from './ports' /** A file in the notes folder (the store watches it: no note or step is on it). */ export { inNotesFolder } from './notesFolder' -/** Closes a new note box, keeping its draft (create.ts closeNoteBox). */ -export const CLOSE_NOTE_BOX = 'codeNotes.closeNoteBox' - /** The id VS Code knows the notes' comment threads by. */ const CONTROLLER_ID = 'codeNotes' @@ -96,15 +93,15 @@ export async function activateNotes(context: vscode.ExtensionContext, ports: Not // A note you made is read (its first message is yours): stored in the background (a round trip to the window). onDidCreateNote((n) => fireAndForget(setSeen([[n.data.id, 1]]), 'seen')), takeLinks((link) => stepLink(ports.layout, link)), - // Esc in a new note box (the key is the manifest's); not in the command table yet, so registered here. - vscode.commands.registerCommand(CLOSE_NOTE_BOX, async () => { + // Esc in a new note box (the key is the manifest's): closes it, keeping its draft (create.ts closeNoteBox). + vscode.commands.registerCommand(HiddenCmd.closeNoteBox, async () => { try { await closeNoteBox() } finally { drafting.fire(false) } }), ) registerCommands(context, { // Adding, replying, asking from a thread. A note being written pauses what plays (its code stays put under it). [Cmd.add]: chord(() => { drafting.fire(true); return addNote() }), - [Cmd.addQuick]: addQuickNote, + [HiddenCmd.addQuick]: addQuickNote, [Cmd.addPathNote]: (uri?: vscode.Uri, text?: unknown) => addPathNote(uri, text), [Cmd.askFromThread]: askFromThread, [Cmd.createFromThread]: async (...a: Parameters) => { @@ -112,7 +109,7 @@ export async function activateNotes(context: vscode.ExtensionContext, ports: Not }, [Cmd.reply]: replyTo, [Cmd.replyReopen]: replyTo, // the same, labelled for resolved threads - [Cmd.replyResolve]: replyAndResolve, + [HiddenCmd.replyResolve]: replyAndResolve, [Cmd.applySuggestion]: (id: string, mi: number, k: number) => applySuggestion(id, mi, k), // Resolving, deleting, moving, reading. [Cmd.resolve]: async (arg?: CommandArg, many?: readonly CommandArg[]) => resolve(await pickNotes(arg, many)), diff --git a/src/platform/commands.ts b/src/platform/commands.ts index 42b9688..078fedd 100644 --- a/src/platform/commands.ts +++ b/src/platform/commands.ts @@ -6,9 +6,8 @@ /** The contributed commands (package.json), by name; the comment is the title the palette shows. */ export const Cmd = { add: 'codeNotes.add', // Add Note - addQuick: 'codeNotes.addQuick', // Add One-Line Note reply: 'codeNotes.reply', // Reply - createFromThread: 'codeNotes.createFromThread', // Add Note + createFromThread: 'codeNotes.createFromThread', // Save Note reveal: 'codeNotes.reveal', // Open Thread resolve: 'codeNotes.resolve', // Resolve reopen: 'codeNotes.reopen', // Reopen @@ -31,10 +30,9 @@ export const Cmd = { find: 'codeNotes.find', // Find Note… refresh: 'codeNotes.refresh', // Reload Notes copyAgentPrompt: 'codeNotes.copyAgentPrompt', // Copy Prompt for Agent - replyResolve: 'codeNotes.replyResolve', // Reply & Resolve hideSession: 'codeNotes.hideSession', // Hide Session in Editor showSession: 'codeNotes.showSession', // Show Session in Editor - showOnlySession: 'codeNotes.showOnlySession', // Show Only This Session + showOnlySession: 'codeNotes.showOnlySession', // Show Only This Session in Editor showAllSessions: 'codeNotes.showAllSessions', // Show All Sessions resolveSession: 'codeNotes.resolveSession', // Resolve Session… deleteSession: 'codeNotes.deleteSession', // Delete Session… @@ -50,7 +48,7 @@ export const Cmd = { restoreBroken: 'codeNotes.restoreBroken', // Restore Last Good Version collapseThread: 'codeNotes.collapseThread', // Show Fewer Replies openJourney: 'codeNotes.openJourney', // Open Journey… - askQuestion: 'codeNotes.askQuestion', // Ask a Question About the Code… + askQuestion: 'codeNotes.askQuestion', // Find or Write a Journey… startJourney: 'codeNotes.startJourney', // Start Journey nextStep: 'codeNotes.nextStep', // Next Step previousStep: 'codeNotes.previousStep', // Previous Step @@ -81,6 +79,11 @@ export const Cmd = { answerCheck: 'codeNotes.answerCheck', // Answer gradeCheck: 'codeNotes.gradeCheck', // Grade the Answer Again checkConcern: 'codeNotes.checkConcern', // Act on a Concern Found During the Check + // A check concern's actions, buttons on its thread. + concernFix: 'codeNotes.concernFix', // Suggest a Fix + concernTodo: 'codeNotes.concernTodo', // Add TODO + concernFlag: 'codeNotes.concernFlag', // Flag for Reviewer + concernDismiss: 'codeNotes.concernDismiss', // Dismiss Concern pickJourneyStep: 'codeNotes.pickJourneyStep', // Pick a Journey Step Here searchJourneys: 'codeNotes.searchJourneys', // Search Journeys sortJourneys: 'codeNotes.sortJourneys', // Sort Journeys @@ -103,12 +106,13 @@ export const HiddenCmd = { podcastFollow: 'codeNotes.podcastFollow', /** A thread's links run through this one with a short key (shortLinks below). */ link: 'codeNotes.link', - /** A check concern's actions on its thread (menus on the thread, not links in the text). */ - concernFix: 'codeNotes.concernFix', - concernTodo: 'codeNotes.concernTodo', - concernFlag: 'codeNotes.concernFlag', + /** A concern marked fixed (the commit that fixes it does this; no button). */ concernFixed: 'codeNotes.concernFixed', - concernDismiss: 'codeNotes.concernDismiss', + /** Not contributed (no menu or key runs them); still registered for keybindings people wrote themselves. */ + addQuick: 'codeNotes.addQuick', + replyResolve: 'codeNotes.replyResolve', + /** Esc in a new note box (the manifest's key). */ + closeNoteBox: 'codeNotes.closeNoteBox', notesFocus: 'codeNotes.notes.focus', journeysFocus: 'codeNotes.journeys.focus', checkFocus: 'codeNotes.check.focus', diff --git a/src/threads/index.ts b/src/threads/index.ts index 2ad932c..95e42e2 100644 --- a/src/threads/index.ts +++ b/src/threads/index.ts @@ -49,11 +49,11 @@ export function activateThreads(context: vscode.ExtensionContext, ports: Threads const call = linkCall(key) return call ? vscode.commands.executeCommand(call.command, ...call.args) : undefined }, - [HiddenCmd.concernFix]: concern('fix'), - [HiddenCmd.concernTodo]: concern('todo'), - [HiddenCmd.concernFlag]: concern('flag'), + [Cmd.concernFix]: concern('fix'), + [Cmd.concernTodo]: concern('todo'), + [Cmd.concernFlag]: concern('flag'), [HiddenCmd.concernFixed]: concern('fixed'), - [HiddenCmd.concernDismiss]: concern('dismiss'), + [Cmd.concernDismiss]: concern('dismiss'), }) return { has: (id) => view.has(id), diff --git a/test/integration/main/threads.ts b/test/integration/main/threads.ts index 17647a7..68c66bb 100644 --- a/test/integration/main/threads.ts +++ b/test/integration/main/threads.ts @@ -10,7 +10,7 @@ import { appendMessage, now, quiet, readJson, test } from '../helpers' import { agentNote, writeLines, writeNote } from '../fixtures' import { cdp, ui } from '../devtools' import { BARS, marksOf } from '../../../src/notes/decorations' -import { HiddenCmd } from '../../../src/platform/commands' +import { Cmd, HiddenCmd } from '../../../src/platform/commands' import { commandLinksIn, ctx, noteById, notePath, snap, until, wsPath } from './context' /* eslint-disable @typescript-eslint/no-explicit-any */ @@ -70,7 +70,7 @@ export const threadsTests = [ await until('tool.json open at line 3', () => vscode.window.activeTextEditor?.document.uri.fsPath === wsPath('tool.json') && vscode.window.activeTextEditor.selection.active.line === 2) const all = await vscode.commands.getCommands(true) - for (const c of [HiddenCmd.link, HiddenCmd.concernFix, HiddenCmd.concernTodo, HiddenCmd.concernFlag, HiddenCmd.concernFixed, HiddenCmd.concernDismiss]) { + for (const c of [HiddenCmd.link, Cmd.concernFix, Cmd.concernTodo, Cmd.concernFlag, HiddenCmd.concernFixed, Cmd.concernDismiss]) { assert.ok(all.includes(c), `${c} is registered (the concern's actions on its thread)`) } }), diff --git a/test/keybindings.test.ts b/test/keybindings.test.ts index 13e77fa..8838623 100644 --- a/test/keybindings.test.ts +++ b/test/keybindings.test.ts @@ -40,12 +40,23 @@ test('one chord scheme on two prefixes: Ctrl+< by scan code (ISO key) and Ctrl+\ } } } - assert.equal(keys.length, PREFIXES.length * Object.keys(CHORDS).length * 2 + 1 /* escape */, 'nothing else but escape') + assert.equal(keys.length, PREFIXES.length * Object.keys(CHORDS).length * 2 + 3, 'nothing else but Esc and Enter (below)') // VS Code shows the last binding of a command: the plain chord, "Ctrl+' D". for (const command of Object.values(CHORDS)) assert.equal(keys.filter((k) => k.command === command).pop()!.key.replace(/^\S+ /, ''), Object.keys(CHORDS).find((k) => CHORDS[k] === command)) assert.ok(keys.some((k) => k.key === 'escape' && k.command === 'codeNotes.cancelMove')) }) +test('outside the chords: Esc and Enter only where they belong to Code Notes', () => { + const others = keys.filter((k) => !k.args) + assert.deepEqual(others, [ + { command: 'codeNotes.cancelMove', key: 'escape', when: 'codeNotes.moving && editorTextFocus && !suggestWidgetVisible && !findWidgetVisible' }, + // Moving a note: Enter puts it on the selection (the status bar item's action). + { command: 'codeNotes.moveToSelection', key: 'enter', when: 'codeNotes.moving && editorTextFocus && !suggestWidgetVisible' }, + // Esc in an empty new note box of ours closes it (the draft is kept); other comment boxes keep their Esc. + { command: 'codeNotes.closeNoteBox', key: 'escape', when: 'commentEditorFocused && commentController == codeNotes && commentThreadIsEmpty' }, + ]) +}) + test('the chord table is the scheme as documented: letters for notes and journeys, arrows and space for listening', async () => { assert.deepEqual((await keymap()).CHORDS, { c: 'codeNotes.add', @@ -63,7 +74,8 @@ test('the chord table is the scheme as documented: letters for notes and journey }) }) -test('every bound command is contributed', () => { +test('every bound command is contributed, except closing the note box (a key, not a verb for the palette)', () => { const cmds = new Set(pkg.contributes.commands.map((c: { command: string }) => c.command)) - for (const k of keys) assert.ok(cmds.has(k.command), k.command) + for (const k of keys.filter((x) => x.command !== 'codeNotes.closeNoteBox')) assert.ok(cmds.has(k.command), k.command) + assert.ok(!cmds.has('codeNotes.closeNoteBox')) }) diff --git a/test/manifest.test.ts b/test/manifest.test.ts index 1f7a1b1..610403d 100644 --- a/test/manifest.test.ts +++ b/test/manifest.test.ts @@ -1,9 +1,11 @@ // What package.json contributes, checked where it can drift by hand: command titles in one style, every command either -// in the palette on purpose or hidden from it, and every setting that picks what runs listed for Restricted Mode. +// in the palette on purpose or hidden from it, and every setting that picks what runs listed for Restricted Mode. Then +// what it promises a user: the description, the empty views' welcome text, the menus and the settings' wording. import { test } from 'node:test' import assert from 'node:assert/strict' import * as fs from 'fs' import * as path from 'path' +import { HiddenCmd } from '../src/platform/commands' type Command = { command: string; title: string } const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf8')) @@ -28,12 +30,9 @@ test('command titles are in Title Case', () => { const IN_PALETTE = [ 'codeNotes.add', 'codeNotes.askQuestion', - 'codeNotes.toggleAnimation', - 'codeNotes.playPodcast', 'codeNotes.checkUnderstanding', 'codeNotes.searchJourneys', - 'codeNotes.sortJourneys', - 'codeNotes.refreshJourney', + 'codeNotes.refresh', ] test('every command is either shown in the palette on purpose or has a commandPalette rule', () => { @@ -58,7 +57,7 @@ test('every setting that picks what runs, its model or its skills is ignored fro * no code writes `stepAsk`, nor `check` on a row, today. */ const CONTEXT_WORDS: Record = { - commentThread: ['asking', 'check', 'open', 'resolved', 'stepAsk'], + commentThread: ['asking', 'check', 'concern', 'open', 'resolved', 'stepAsk', 'todo'], viewItem: ['asking', 'broken', 'check', 'hidden', 'journey', 'known', 'named', 'note', 'open', 'podcast', 'replied', 'resolved', 'session', 'shown', 'stale', 'unread'], } @@ -72,3 +71,142 @@ test('the menus look for known context words only', () => { } for (const key of Object.keys(CONTEXT_WORDS)) assert.deepEqual([...found[key]].sort(), CONTEXT_WORDS[key], key) }) + +type Menu = { command: string; when?: string; group?: string } +const c = pkg.contributes +const menus: Record = c.menus +const settings: Record = c.configuration.properties +const titleOf = (id: string) => commands.find((x) => x.command === id)?.title +const menu = (where: string, command: string) => menus[where].filter((m) => m.command === command) +const describe = (key: string) => settings[key].description ?? settings[key].markdownDescription ?? '' + +test('the description names notes, journeys and the merge-request check in one line', () => { + assert.doesNotMatch(pkg.description, /\n/) + for (const word of [/\bnotes\b/, /\bjourneys\b/, /\bcheck\b/, /\bmerge\b/]) assert.match(pkg.description, word) +}) + +test('an empty Journeys view: one line and a button that writes a journey', () => { + const welcome = c.viewsWelcome.filter((w: { view: string }) => w.view === 'codeNotes.journeys') + assert.equal(welcome.length, 1) + const lines: string[] = welcome[0].contents.split('\n') + assert.equal(lines.length, 2) + assert.doesNotMatch(lines[0], /\[/, 'the first line is text') + assert.equal(lines[1], '[Ask a Question About the Code…](command:codeNotes.askQuestion)') +}) + +test('with journeys, the Journeys view\'s … menu offers the tutorial', () => { + assert.deepEqual(menu('view/title', 'codeNotes.tutorial'), [ + { command: 'codeNotes.tutorial', when: 'view == codeNotes.journeys && codeNotes.hasJourneys', group: '1_help@1' }, + ]) +}) + +test('no walkthrough: the empty views carry the first-run text', () => { + assert.equal(c.walkthroughs, undefined) +}) + +test('no two contributed commands share a title; the unreachable one-line note and Reply & Resolve are gone', () => { + const titles = commands.map((x) => x.title) + assert.deepEqual(titles.filter((t, i) => titles.indexOf(t) !== i), []) + for (const id of ['codeNotes.addQuick', 'codeNotes.replyResolve']) { + assert.equal(titleOf(id), undefined, id) + for (const items of Object.values(menus)) assert.ok(!items.some((m) => m.command === id), id) + } + assert.equal(titleOf('codeNotes.createFromThread'), 'Save Note') +}) + +test('every command the code registers is contributed, or internal by name here', () => { + const internal = [ + 'codeNotes.askStepUpdate', 'codeNotes.claudeLinkBack', 'codeNotes.codeLink', 'codeNotes.codeLinkBack', + 'codeNotes.nextCheckQuestion', 'codeNotes.openNoteId', 'codeNotes.openStepLink', 'codeNotes.podcastFollow', + 'codeNotes.link', 'codeNotes.concernFixed', 'codeNotes.addQuick', 'codeNotes.replyResolve', 'codeNotes.closeNoteBox', + 'codeNotes.notes.focus', 'codeNotes.journeys.focus', 'codeNotes.check.focus', + ] + assert.deepEqual(Object.values(HiddenCmd).sort(), [...internal].sort()) + const contributed = new Set(commands.map((x) => x.command)) + for (const id of internal) assert.ok(!contributed.has(id), `${id} is internal`) +}) + +test('the inbox actions that need no row are in the palette; Reload Notes is in the Notes view\'s … menu too', () => { + const ids = ['markAllRead', 'resolveAll', 'deleteResolved', 'filter', 'refresh', 'copyAgentPrompt', 'nextUnread', + 'previousUnread', 'groupByFile', 'groupBySession', 'showResolved', 'hideResolved', 'showAllSessions'] + for (const id of ids.map((x) => `codeNotes.${x}`)) { + assert.ok(titleOf(id), id) + assert.ok(menu('commandPalette', id).every((m) => m.when !== 'false'), `${id} in the palette`) + } + assert.deepEqual(menu('view/title', 'codeNotes.refresh'), [{ command: 'codeNotes.refresh', when: 'view == codeNotes.notes', group: '3_reload@1' }]) + assert.equal(titleOf('codeNotes.refresh'), 'Reload Notes') +}) + +test('journey commands are in the palette only where there are journeys', () => { + for (const id of ['refreshJourney', 'playPodcast', 'sortJourneys', 'toggleAnimation']) { + assert.deepEqual(menu('commandPalette', `codeNotes.${id}`).map((m) => m.when), ['codeNotes.hasJourneys'], id) + } +}) + +test('titles say what they do', () => { + assert.equal(titleOf('codeNotes.showOnlySession'), 'Show Only This Session in Editor') + assert.equal(titleOf('codeNotes.askQuestion'), 'Find or Write a Journey…') + assert.equal(titleOf('codeNotes.askClaude'), 'Ask Claude') +}) + +test('the note bar: the setting says bar, and no unused background colour', () => { + assert.equal(describe('codeNotes.highlight'), 'Show a bar beside lines with an open note.') + assert.ok(!c.colors.some((x: { id: string }) => x.id === 'codeNotes.noteBackground')) +}) + +test('VS Code\'s comment height cap is left alone', () => { + assert.ok(!('comments.maxHeight' in c.configurationDefaults)) +}) + +test('model settings: one-line descriptions, the four models as suggestions; Claude: Mode reads as behaviour', () => { + for (const key of ['codeNotes.claude.model', 'codeNotes.journeys.model', 'codeNotes.understanding.model']) { + assert.deepEqual(settings[key].examples, ['sonnet', 'opus', 'haiku', 'fable'], key) + assert.equal(settings[key].enum, undefined, `${key} still takes any model id`) + assert.ok(describe(key).length <= 100, `${key}: ${describe(key)}`) + } + const mode = settings['codeNotes.claude.mode'] + assert.deepEqual(mode.enum, ['button', 'always', 'off'], 'stored values unchanged') + assert.deepEqual(mode.enumItemLabels, ['When I ask', 'Every note', 'Never']) + assert.ok(describe('codeNotes.claude.mode').length <= 100) +}) + +test('background questions: the description says where they run', () => { + assert.equal(describe('codeNotes.understanding.background'), 'Writes the questions with Claude when a branch is pushed, in repositories that use the check.') +}) + +test('Ask Claude is a labelled button beside Reply on open notes; Stop has its own title slot', () => { + const ask = menu('comments/commentThread/context', 'codeNotes.askClaude') + assert.equal(ask.length, 1) + assert.equal(ask[0].group, 'inline@2') + for (const part of ['commentController == codeNotes', "config.codeNotes.claude.mode != 'off'", 'codeNotes.claudeFound', 'commentThread =~ /open/', '!(commentThread =~ /check/)']) { + assert.ok(ask[0].when!.includes(part), part) + } + const title = menus['comments/commentThread/title'] + const stop = title.find((m) => m.command === 'codeNotes.cancelClaude')! + assert.equal(stop.group, 'navigation@1') + assert.ok(!title.some((m) => m.command !== stop.command && m.group === stop.group), 'nothing else in Stop\'s slot') +}) + +test('a check concern\'s actions are named buttons on its thread', () => { + const want = { concernFix: 'Suggest a Fix', concernTodo: 'Add TODO', concernFlag: 'Flag for Reviewer', concernDismiss: 'Dismiss Concern' } + for (const [name, title] of Object.entries(want)) { + const id = `codeNotes.${name}` + assert.equal(titleOf(id), title) + const m = menu('comments/commentThread/context', id) + assert.equal(m.length, 1, id) + assert.match(m[0].when!, /commentThread =~ \/concern\//) + assert.match(m[0].group!, /^inline@/) + assert.deepEqual(menu('commandPalette', id).map((x) => x.when), ['false'], `${id} needs a thread`) + } +}) + +test('the Check view is hidden on the default branch without a check', () => { + assert.equal(c.views.codeNotes.find((v: { id: string }) => v.id === 'codeNotes.check').when, '!codeNotes.checkOnBase') +}) + +test('the docs the README links ship in the package', () => { + for (const doc of ['docs/journey-format.md', 'docs/understanding-check.md', 'docs/agent-protocol.md']) { + assert.ok(pkg.files.includes(doc), doc) + assert.ok(fs.existsSync(path.join(__dirname, '../..', doc)), doc) + } +})