continue-custom/extensions/cli/src/slashCommands.remote.test.ts
Nate Sesti b12499cb0e
feat: show remote sessions in cn ls (#7694)
* feat: /title slash command

* fix: /title slash command should be able to be submitted with text

* test: add tests for last commit's changes

* fix: EOF in action.yml

* feat: list remote sessions in cn ls and /resume

* feat: load more sessions and make them scrollable

* chore: format

* improv: debug script builds automatically for cli

* feat: load remote session

* fix: wrap entrypoint in function so it doesn't run at import-time

* feat: /diff and /apply slash commands for cn remote

* feat: full screen diff viewer

* feat: status message for /apply slash command

* Update extensions/cli/src/ui/UserInput.tsx

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* fix: remove console.logs

* Potential fix for code scanning alert no. 60: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 61: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix: build.js

* feat: list remote sessions in history of extensions

* feat: open remote agents in browser

* chore: fix tests and lint

* fix: import Text

* fix: small bug

* fix: address feedback

* fix: adjust extension gui for compatibility with cli session history

* feat: load session history from remote

* feat: open remote session in browser

* fix: tests, linting, formatting

* fix: don't use any

* address nitpicks

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-09-19 22:44:26 -07:00

52 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi, beforeEach } from "vitest";
import { handleSlashCommands } from "./slashCommands.js";
describe("Remote mode slash commands", () => {
const mockAssistant = {
name: "test",
version: "1.0.0",
prompts: [],
};
beforeEach(() => {
vi.clearAllMocks();
});
describe("/diff and /apply commands", () => {
it("should not be handled by handleSlashCommands - these are handled by TUI layer", async () => {
// /diff and /apply are handled by handleSpecialCommands in useChat.helpers.ts,
// not by the general slash command system. These commands are intercepted
// at the TUI layer before reaching handleSlashCommands, so handleSlashCommands
// should return null (no match) for these commands.
const diffResult = await handleSlashCommands("/diff", mockAssistant);
expect(diffResult).toBe(null);
const applyResult = await handleSlashCommands("/apply", mockAssistant);
expect(applyResult).toBe(null);
});
it("should return unknown command for remote commands when called directly", async () => {
// When called directly (bypassing handleSpecialCommands), /diff and /apply
// should return "Unknown command" because they're listed in REMOTE_MODE_SLASH_COMMANDS
// for UI display but not implemented as handlers.
const diffResult = await handleSlashCommands("/diff", mockAssistant, {
remoteUrl: "http://localhost:3000",
isRemoteMode: true,
});
expect(diffResult).toEqual({
output: "Unknown command: diff",
});
const applyResult = await handleSlashCommands("/apply", mockAssistant, {
remoteUrl: "http://localhost:3000",
isRemoteMode: true,
});
expect(applyResult).toEqual({
output: "Unknown command: apply",
});
});
});
});