mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:32:44 +00:00
tui: add local shell execution for !-prefixed lines
This commit is contained in:
committed by
Peter Steinberger
parent
c1e50b7184
commit
5fd699d0bf
@@ -13,6 +13,7 @@ describe("createEditorSubmitHandler", () => {
|
||||
editor,
|
||||
handleCommand: vi.fn(),
|
||||
sendMessage: vi.fn(),
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler("hello world");
|
||||
@@ -21,7 +22,7 @@ describe("createEditorSubmitHandler", () => {
|
||||
expect(editor.addToHistory).toHaveBeenCalledWith("hello world");
|
||||
});
|
||||
|
||||
it("trims input before adding to history", () => {
|
||||
it("does not trim input before adding to history", () => {
|
||||
const editor = {
|
||||
setText: vi.fn(),
|
||||
addToHistory: vi.fn(),
|
||||
@@ -31,14 +32,15 @@ describe("createEditorSubmitHandler", () => {
|
||||
editor,
|
||||
handleCommand: vi.fn(),
|
||||
sendMessage: vi.fn(),
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler(" hi ");
|
||||
|
||||
expect(editor.addToHistory).toHaveBeenCalledWith("hi");
|
||||
expect(editor.addToHistory).toHaveBeenCalledWith(" hi ");
|
||||
});
|
||||
|
||||
it("does not add empty submissions to history", () => {
|
||||
it("does not add empty-string submissions to history", () => {
|
||||
const editor = {
|
||||
setText: vi.fn(),
|
||||
addToHistory: vi.fn(),
|
||||
@@ -48,9 +50,10 @@ describe("createEditorSubmitHandler", () => {
|
||||
editor,
|
||||
handleCommand: vi.fn(),
|
||||
sendMessage: vi.fn(),
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler(" ");
|
||||
handler("");
|
||||
|
||||
expect(editor.addToHistory).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -67,6 +70,7 @@ describe("createEditorSubmitHandler", () => {
|
||||
editor,
|
||||
handleCommand,
|
||||
sendMessage,
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler("/models");
|
||||
@@ -88,6 +92,7 @@ describe("createEditorSubmitHandler", () => {
|
||||
editor,
|
||||
handleCommand,
|
||||
sendMessage,
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler("hello");
|
||||
@@ -96,4 +101,42 @@ describe("createEditorSubmitHandler", () => {
|
||||
expect(sendMessage).toHaveBeenCalledWith("hello");
|
||||
expect(handleCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("routes bang-prefixed lines to handleBangLine", () => {
|
||||
const editor = {
|
||||
setText: vi.fn(),
|
||||
addToHistory: vi.fn(),
|
||||
};
|
||||
const handleBangLine = vi.fn();
|
||||
|
||||
const handler = createEditorSubmitHandler({
|
||||
editor,
|
||||
handleCommand: vi.fn(),
|
||||
sendMessage: vi.fn(),
|
||||
handleBangLine,
|
||||
});
|
||||
|
||||
handler("!ls");
|
||||
|
||||
expect(handleBangLine).toHaveBeenCalledWith("!ls");
|
||||
});
|
||||
|
||||
it("treats a lone ! as a normal message", () => {
|
||||
const editor = {
|
||||
setText: vi.fn(),
|
||||
addToHistory: vi.fn(),
|
||||
};
|
||||
const sendMessage = vi.fn();
|
||||
|
||||
const handler = createEditorSubmitHandler({
|
||||
editor,
|
||||
handleCommand: vi.fn(),
|
||||
sendMessage,
|
||||
handleBangLine: vi.fn(),
|
||||
});
|
||||
|
||||
handler("!");
|
||||
|
||||
expect(sendMessage).toHaveBeenCalledWith("!");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user