Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,44 @@ describe("createStore", () => {
const session = store.handleEvent({
session_id: "s1",
hook_event_name: "PreToolUse",
tool_name: "Bash",
tool_name: "Read",
});
assert.equal(session?.status, "running");
assert.equal(session?.lastEvent, "Read");
});

it("PreToolUse with Bash transitions to waiting", () => {
const store = createStore();
store.handleEvent({ session_id: "s1", hook_event_name: "SessionStart" });
store.handleEvent({
session_id: "s1",
hook_event_name: "UserPromptSubmit",
});
const session = store.handleEvent({
session_id: "s1",
hook_event_name: "PreToolUse",
tool_name: "Bash",
});
assert.equal(session?.status, "waiting");
assert.equal(session?.lastEvent, "Bash");
});

it("PreToolUse with Write transitions to waiting", () => {
const store = createStore();
store.handleEvent({ session_id: "s1", hook_event_name: "SessionStart" });
store.handleEvent({
session_id: "s1",
hook_event_name: "UserPromptSubmit",
});
const session = store.handleEvent({
session_id: "s1",
hook_event_name: "PreToolUse",
tool_name: "Write",
});
assert.equal(session?.status, "waiting");
assert.equal(session?.lastEvent, "Write");
});

it("PreToolUse without tool_name falls back to PreToolUse display", () => {
const store = createStore();
store.handleEvent({ session_id: "s1", hook_event_name: "SessionStart" });
Expand Down
9 changes: 8 additions & 1 deletion src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ const EVENT_TO_STATUS: Record<string, SessionStatus> = {
Stop: "done",
};

const INTERACTIVE_TOOLS = new Set(["ExitPlanMode", "AskUserQuestion"]);
const INTERACTIVE_TOOLS = new Set([
"ExitPlanMode",
"AskUserQuestion",
"Bash",
"Write",
"Edit",
"NotebookEdit",
]);

export function createStore(): Store {
const sessions = new Map<string, Session>();
Expand Down