feat: stop all servers button#2323
Conversation
|
@arnestrickmann would love some design input aswell :'D |
Greptile SummaryThis PR adds a task-scoped "Stop all servers" control to the dev server pill in the task titlebar, replacing the flat pill list with a Popover that shows individual stop buttons per server and a bulk stop action. It also fixes a pre-existing respawn bug in both
Confidence Score: 5/5Safe to merge — the changes are well-scoped, covered by targeted tests, and the one intentional trade-off (optimistic pill removal on Ctrl+C) is documented in-code. The stop flow is straightforward: Ctrl+C or lifecycle coordinator, then an optimistic exit event. The cleanup registry correctly deduplicates events via the found closure flag, and the terminal-provider pre-kill cleanup order is verified by the new synchronous-exit respawn tests. No unbounded side-effects or cross-session leakage were identified. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/core/terminals/stopDevServers.ts | New RPC handler dispatching Ctrl+C for normal terminals or lifecycle coordinator for run scripts; optimistically hides pills via emitDevServerExit with intentional comment about SIGINT-ignoring processes |
| src/main/core/terminals/dev-server-watcher.ts | Adds module-level activeDevServerCleanups map keyed by scopeId:terminalId and exports clearTerminalDevServer; cleanup is registered on URL detection and safely de-dupes exit events via the found flag |
| src/renderer/features/tasks/components/dev-server-pills.tsx | Major UI rework replacing flat pill list with a Popover that has individual Stop buttons per server and a Stop all servers button; uses callback-ref mountedRef pattern to guard the stoppingKey setState after unmount |
| src/renderer/features/tasks/stores/dev-server-store.ts | Map key upgraded from plain terminalId to scopeId:terminalId composite, entry type enriched with scopeId and terminalId fields needed for targeted stop RPC |
| src/main/core/terminals/impl/local-terminal-provider.ts | Bug fix: session maps cleared before pty.kill() to prevent synchronous exit callback from seeing stale state and triggering an unintended respawn; respawnCounts is now also cleaned up |
| src/main/core/terminals/impl/ssh-terminal-provider.ts | Same pre-kill cleanup fix as local-terminal-provider; terminals map and shellProfiles are now cleared before pty.kill() to prevent respawn on synchronous exit |
| src/main/core/terminals/stopDevServers.test.ts | Comprehensive tests covering normal interrupt, watcher cleanup deduplication, lifecycle coordinator path, and PTY kill fallback |
| src/main/core/terminals/impl/local-terminal-provider.test.ts | Adds session tracking to mock and a new test verifying that a synchronous kill exit does not trigger a respawn |
| src/main/core/terminals/impl/ssh-terminal-provider.test.ts | Mirrors the local provider test changes: session array tracking in mock and a new no-respawn-on-kill test |
| src/main/core/terminals/controller.ts | Registers stopDevServers in the RPC controller, minimal one-line change |
Sequence Diagram
sequenceDiagram
participant UI as DevServerPills (Renderer)
participant RPC as rpc.terminals
participant SD as stopDevServers.ts
participant DSW as dev-server-watcher.ts
participant LC as lifecycle-script-coordinator
participant PTY as PTY / ptySessionRegistry
participant Store as DevServerStore
UI->>RPC: "stopDevServers({ projectId, taskId, workspaceId, servers })"
RPC->>SD: stopDevServers(...)
loop for each server
alt "scopeId === workspaceId && terminalId === run script"
SD->>LC: stopLifecycleScriptSession(...)
LC-->>SD: stopped: boolean
alt not stopped
SD->>PTY: pty.kill() + unregister
end
else normal terminal
SD->>PTY: pty.write(Ctrl+C)
end
SD->>DSW: clearTerminalDevServer(scopeId, terminalId)
alt watcher cleanup found
DSW->>DSW: cleanup() - stopProbe, delete map entry
DSW-->>Store: emit hostPreviewEvent type exit
DSW-->>SD: true (skip manual emit)
else no cleanup registered
SD-->>Store: emit hostPreviewEvent type exit
end
end
Store->>UI: entries updated (pill removed)
UI->>UI: setStoppingKey(null) if still mounted
Reviews (2): Last reviewed commit: "feat(terminals): add dev servers menu" | Re-trigger Greptile
|
update: https://streamable.com/4cpji0 |
Description
Screenshot/Recording (if applicable)
https://streamable.com/1i4wux
Checklist
messages and, when possible, the PR title