Files
OpenResearch/ui/tests/bashCommand.test.mjs
T
Myles AndersonandClaude Fable 5.1 56ed86d466 feat: ! bash mode in the chat composer (#283)
A draft that opens with `!` is a shell command, as in Claude Code: the
composer turns amber with a Bash chip, Enter (or the Run button) runs it
in the session's worktree through POST /api/chat/sessions/{id}/shell,
and the exchange lands on the transcript as a user-side card. Commands
run since the last real message are folded into the next turn's prompt
as untrusted context. Output is capped, the process group is killed on
timeout, and a backgrounded child cannot hold the request open.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-03 17:03:27 -07:00

21 lines
720 B
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { bashCommand, withoutBashPrefix } from "../src/bashCommand.ts";
test("a leading ! turns the draft into a shell command", () => {
assert.equal(bashCommand("!ls -la"), "ls -la");
assert.equal(bashCommand("! git status "), "git status");
assert.equal(bashCommand("!"), "");
});
test("only the first character counts", () => {
assert.equal(bashCommand("ls !"), null);
assert.equal(bashCommand(" !ls"), null);
assert.equal(bashCommand(""), null);
});
test("leaving the mode keeps whatever was typed after the prefix", () => {
assert.equal(withoutBashPrefix("!ls"), "ls");
assert.equal(withoutBashPrefix("plain"), "plain");
});