-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(desktop): add restart prompt for terminal persistence toggle and show sessions regardless of mode #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
156b0fc
7a05f0c
f70ca2a
6907634
3d264ff
27a76ff
b819a6f
7545661
d12322a
efef720
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,11 +11,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||
| Tray, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "electron"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { localDb } from "main/lib/local-db"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| getActiveTerminalManager, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| isDaemonModeEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "main/lib/terminal"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { DaemonTerminalManager } from "main/lib/terminal/daemon-manager"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { tryListExistingDaemonSessions } from "main/lib/terminal"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getTerminalHostClient } from "main/lib/terminal-host/client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { ListSessionsResponse } from "main/lib/terminal-host/types"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -118,9 +114,10 @@ function openSessionInSuperset(workspaceId: string): void { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| async function killAllSessions(): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const manager = getActiveTerminalManager(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (manager instanceof DaemonTerminalManager) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await manager.forceKillAll(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const client = getTerminalHostClient(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const connected = await client.tryConnectAndAuthenticate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (connected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await client.killAll({}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("[Tray] Killed all daemon sessions"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
115
to
121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log when terminal host is unavailable to avoid silent no-ops. 🔧 Suggested tweak- const connected = await client.tryConnectAndAuthenticate();
- if (connected) {
- await client.killAll({});
- console.log("[Tray] Killed all daemon sessions");
- }
+ const connected = await client.tryConnectAndAuthenticate();
+ if (!connected) {
+ console.warn("[Tray/killAllSessions] Terminal host unavailable; no sessions killed");
+ } else {
+ await client.killAll({});
+ console.log("[Tray] Killed all daemon sessions");
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -132,9 +129,10 @@ async function killAllSessions(): Promise<void> { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| async function killSession(paneId: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const manager = getActiveTerminalManager(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (manager instanceof DaemonTerminalManager) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await manager.kill({ paneId, deleteHistory: false }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const client = getTerminalHostClient(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const connected = await client.tryConnectAndAuthenticate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (connected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await client.kill({ sessionId: paneId }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`[Tray] Killed session: ${paneId}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -167,7 +165,7 @@ function formatSessionLabel( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| function buildSessionsSubmenu( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sessions: ListSessionsResponse["sessions"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| daemonEnabled: boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| daemonRunning: boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ): MenuItemConstructorOptions[] { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const aliveSessions = sessions.filter((s) => s.isAlive); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const menuItems: MenuItemConstructorOptions[] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -222,7 +220,7 @@ function buildSessionsSubmenu( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| menuItems.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Restart Daemon", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: daemonEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: daemonRunning, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| click: restartDaemon, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -245,22 +243,10 @@ async function restartDaemon(): Promise<void> { | |||||||||||||||||||||||||||||||||||||||||||||||||
| async function updateTrayMenu(): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!tray) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const daemonEnabled = isDaemonModeEnabled(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let sessionCount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let sessions: ListSessionsResponse["sessions"] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (daemonEnabled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const manager = getActiveTerminalManager(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (manager instanceof DaemonTerminalManager) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = await manager.listDaemonSessions(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sessions = result.sessions; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sessionCount = sessions.filter((s) => s.isAlive).length; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch {} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const { daemonRunning, sessions } = await tryListExistingDaemonSessions(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const sessionCount = sessions.filter((s) => s.isAlive).length; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const sessionsSubmenu = buildSessionsSubmenu(sessions, daemonEnabled); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const sessionsSubmenu = buildSessionsSubmenu(sessions, daemonRunning); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const sessionsLabel = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sessionCount > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ? `Background Sessions (${sessionCount})` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.