Track per-thread terminal running state in UI and store #19
Mergedjuliusmarmingemerged 5 commits into
main fromcodething/696df84fmerged by juliusmarminge View on GitHub- @@ -373,3 +387,17 @@373387 };374388 }375389390+ case "APPLY_TERMINAL_EVENT":391+ if (!state.threads.some((thread) => thread.id === action.event.threadId)) {392+ return state;393+ }394+ return {395+ ...state,396+ threads: updateThread(state.threads, action.event.threadId, (t) => ({397+ ...t,398+ terminalRunning:399+ action.event.type === "started" || action.event.type === "restarted"400+ ? action.event.snapshot.status === "running"401+ : action.event.type === "exited" || action.event.type === "error"402+ ? false403+ : t.terminalRunning,
- @@ -77,0 +89,21 @@89+ status: "running",90+ pid: 1234,91+ history: "",92+ exitCode: null,93+ exitSignal: null,94+ updatedAt: "2026-02-09T00:00:01.000Z",95+ },96+ ...overrides,97+ };98+}99+100+function makeTerminalActivityEvent(overrides: Partial<TerminalEvent> = {}): TerminalEvent {101+ return {102+ type: "activity",103+ threadId: "thread-local-1",104+ terminalId: DEFAULT_THREAD_TERMINAL_ID,105+ createdAt: "2026-02-09T00:00:02.000Z",106+ hasRunningSubprocess: true,107+ ...overrides,108+ };109+}
- @@ -334,7 +427,8 @@334427 if (input.deleteHistory) {335428 await this.deleteAllHistoryForThread(input.threadId);336429 }430+ this.updateSubprocessPollingState();337431 });338432 }339433340434 dispose(): void {
- @@ -600,8 +704,10 @@600704 return "";601705 }602706707+ const legacyPath = this.legacyHistoryPath(threadId);603708 try {604- const raw = await fs.promises.readFile(this.legacyHistoryPath(threadId), "utf8");709+ const raw = await fs.promises.readFile(legacyPath, "utf8");605710 const capped = capHistory(raw, this.historyLineLimit);606- if (capped !== raw) {607- await fs.promises.writeFile(this.legacyHistoryPath(threadId), capped, "utf8");711+712+ // Migrate legacy transcript filename to the terminal-scoped path.713+ await fs.promises.writeFile(nextPath, capped, "utf8");
juliusmarminge merged this804572c
juliusmarminge closed this
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
Walkthrough#
Adds terminal lifecycle tracking: threads gain
runningTerminalIds; store handlesAPPLY_TERMINAL_EVENT; UI shows Terminal status and improved close behavior; server adds subprocess activity polling and migrates terminal-scoped history files; contracts add an "activity" terminal event variant; tests updated accordingly.Changes#
apps/web/src/types.ts,apps/web/src/store.ts,apps/web/src/App.tsxrunningTerminalIds: string[]toThread; importedTerminalEvent; addedAPPLY_TERMINAL_EVENTaction and reducer logic; App effect listens for terminal events and dispatches them.apps/web/src/components/Sidebar.tsx,apps/web/src/components/ChatView.tsxTerminalstatus pill,terminalStatusPill()helper, and initializerunningTerminalIdsfor new threads. ChatView: updated terminal-close flow to callapi.terminal.close(...)when available, otherwise fall back to writing"exit\n"; adjusted effect deps.apps/web/src/persistenceSchema.ts,apps/web/src/persistenceSchema.test.tsrunningTerminalIds: []; tests updated to include the new field.apps/web/src/store.test.tsTerminalEventimports, test helpers, and multiple tests assertingrunningTerminalIdslifecycle across start, activity, exit, close, and multi-terminal scenarios.apps/server/src/terminalManager.ts,apps/server/src/terminalManager.test.tspackages/contracts/src/terminal.ts,packages/contracts/src/terminal.test.tsterminalActivityEventSchema(type"activity",hasRunningSubprocess: boolean) and extendedterminalEventSchemaunion; test added to validate activity events.Sequence Diagram#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~50 minutes
🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
⚔️
README.md(content)⚔️
apps/server/package.json(content)⚔️
apps/server/src/terminalManager.test.ts(content)⚔️
apps/server/src/terminalManager.ts(content)⚔️
apps/web/src/App.tsx(content)⚔️
apps/web/src/components/ChatView.tsx(content)⚔️
apps/web/src/components/Sidebar.tsx(content)⚔️
apps/web/src/persistenceSchema.test.ts(content)⚔️
apps/web/src/persistenceSchema.ts(content)⚔️
apps/web/src/store.test.ts(content)⚔️
apps/web/src/store.ts(content)⚔️
apps/web/src/types.ts(content)⚔️
package.json(content)⚔️
packages/contracts/src/terminal.test.ts(content)⚔️
packages/contracts/src/terminal.ts(content)⚔️
turbo.json(content)These conflicts must be resolved before merging into
main.✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.