|
| 1 | +import { describe, expect, it, vi } from "vitest"; |
| 2 | +import { |
| 3 | + createTuiCommandCatalog, |
| 4 | + type TuiCommandContext, |
| 5 | +} from "../../../../src/tui/commands/catalog.js"; |
| 6 | + |
| 7 | +describe("MiniMax Code TUI command catalog in side conversations", () => { |
| 8 | + const sideContext: TuiCommandContext = { |
| 9 | + hasSession: true, |
| 10 | + hasParentSession: true, |
| 11 | + managedTokenPresent: true, |
| 12 | + queueEnabled: true, |
| 13 | + hasLiveRun: false, |
| 14 | + hasPendingInteraction: false, |
| 15 | + queuedCount: 0, |
| 16 | + canRetry: false, |
| 17 | + sideMode: true, |
| 18 | + }; |
| 19 | + |
| 20 | + it("lets a side conversation run diagnostics and send feedback in place", async () => { |
| 21 | + const doctorHandler = vi.fn(); |
| 22 | + const feedbackHandler = vi.fn(); |
| 23 | + const quitHandler = vi.fn(); |
| 24 | + const catalog = createTuiCommandCatalog( |
| 25 | + [], |
| 26 | + { doctor: doctorHandler, feedback: feedbackHandler, quit: quitHandler }, |
| 27 | + () => sideContext, |
| 28 | + ); |
| 29 | + |
| 30 | + await expect(catalog.dispatch("/doctor")).resolves.toMatchObject({ status: "handled" }); |
| 31 | + await expect(catalog.dispatch("/feedback side reply failed")).resolves.toMatchObject({ |
| 32 | + status: "handled", |
| 33 | + }); |
| 34 | + expect(doctorHandler).toHaveBeenCalledOnce(); |
| 35 | + expect(feedbackHandler).toHaveBeenCalledOnce(); |
| 36 | + |
| 37 | + // /quit stays blocked: leaving from the side view would abort only the |
| 38 | + // side Turn and skip side cleanup, unlike quitting from the main view. |
| 39 | + await expect(catalog.dispatch("/quit")).resolves.toMatchObject({ status: "unavailable" }); |
| 40 | + expect(quitHandler).not.toHaveBeenCalled(); |
| 41 | + }); |
| 42 | + |
| 43 | + it("keeps commands that mutate Sessions unavailable in a side conversation", async () => { |
| 44 | + const sessionsHandler = vi.fn(); |
| 45 | + const catalog = createTuiCommandCatalog([], { sessions: sessionsHandler }, () => sideContext); |
| 46 | + |
| 47 | + await expect(catalog.dispatch("/sessions")).resolves.toMatchObject({ |
| 48 | + status: "unavailable", |
| 49 | + reason: expect.stringContaining("unavailable in side conversations"), |
| 50 | + }); |
| 51 | + expect(sessionsHandler).not.toHaveBeenCalled(); |
| 52 | + }); |
| 53 | +}); |
0 commit comments