diff --git a/src/downshift.test.ts b/src/downshift.test.ts index a0657b7..2771a94 100644 --- a/src/downshift.test.ts +++ b/src/downshift.test.ts @@ -67,6 +67,7 @@ function createContext(usage: { const status = vi.fn(); const select = vi.fn(); const input = vi.fn(); + const notify = vi.fn(); const ctx = { hasUI: true, getContextUsage: () => usage.current, @@ -74,13 +75,14 @@ function createContext(usage: { setStatus: status, select, input, - notify: vi.fn(), + notify, }, }; return { commandContext: ctx as unknown as ExtensionCommandContext, context: ctx as unknown as ExtensionContext, input, + notify, select, status, }; @@ -123,7 +125,7 @@ describe("downshift lifecycle adapter", () => { expect(handlers.has("thinking_level_select")).toBe(true); }); - it("refreshes status immediately after saving configuration", async () => { + it("opens configuration for the bare command", async () => { const usage = { current: { tokens: 100, percent: 10 } }; const { commands } = createExtension(); const { commandContext, select, input, status } = createContext(usage); @@ -144,4 +146,39 @@ describe("downshift lifecycle adapter", () => { status.mock.invocationCallOrder[0], ); }); + + it("warns with help for the unsupported config subcommand", async () => { + const { commands } = createExtension(); + const { commandContext, notify } = createContext({ + current: { tokens: 100, percent: 10 }, + }); + + await commands.get("downshift")?.("config", commandContext); + + expect(notify).toHaveBeenCalledWith( + expect.stringContaining("/downshift - configure Downshift"), + "warning", + ); + expect(fsMocks.writeFile).not.toHaveBeenCalled(); + }); + + it("does not advertise the unsupported config subcommand in help or status", async () => { + const { commands } = createExtension(); + const { commandContext, notify } = createContext({ + current: { tokens: 100, percent: 10 }, + }); + + await commands.get("downshift")?.("help", commandContext); + expect(notify).toHaveBeenCalledWith( + expect.not.stringContaining("/downshift config"), + "info", + ); + + notify.mockClear(); + await commands.get("downshift")?.("status", commandContext); + expect(notify).toHaveBeenCalledWith( + expect.not.stringContaining("/downshift config"), + "info", + ); + }); }); diff --git a/src/downshift.ts b/src/downshift.ts index ae6fcab..b01dd02 100644 --- a/src/downshift.ts +++ b/src/downshift.ts @@ -724,7 +724,7 @@ const STATUS_LINE_BUILDERS: Array< (config) => `upshift: ${yesNoMode(config?.upshiftAfterCompaction, "on")}`, (config) => `source: ${config?.premiumSource ?? "current"}`, () => `version: ${VERSION}`, - () => `commands: /downshift status | now | config | on | off | help`, + () => `commands: /downshift | status | now | on | off | help`, ]; function formatOptionalRemaining( diff --git a/tsconfig.json b/tsconfig.json index 00f23d2..9fb2683 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,5 +9,5 @@ "noEmit": true, "types": ["node", "vitest/globals"] }, - "include": ["downshift.ts", "src/**/*.ts"] + "include": ["index.ts", "src/**/*.ts"] }