Repository navigation
Fix stale terminal agent tab icons #7740
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 2 commits
71a0cd6
d518440
a0a7257
5fc34c8
8637a2a
28a9cea
e816837
74f1c5e
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 |
|---|---|---|
|
|
@@ -176,29 +176,35 @@ extension Workspace { | |
| var didMutatePanelTitle = false | ||
| var didMutateWorkspaceTitle = false | ||
| var didMutateTitleDerivedAgent = false | ||
| var didPruneStaleAgentRuntime = false | ||
|
|
||
| if panelTitles[panelId] != trimmed { | ||
| panelTitles[panelId] = trimmed | ||
| didMutate = true | ||
| didMutatePanelTitle = true | ||
| } | ||
|
|
||
| if panels[panelId] is TerminalPanel, | ||
| updateTitleDerivedTerminalAgentStatusKey(forPanelId: panelId, title: trimmed) { | ||
| didMutate = true | ||
| didMutateTitleDerivedAgent = true | ||
| if panels[panelId] is TerminalPanel { | ||
| if updateTitleDerivedTerminalAgentStatusKey(forPanelId: panelId, title: trimmed) { | ||
| didMutate = true | ||
| didMutateTitleDerivedAgent = true | ||
| } | ||
| if clearStaleAgentPIDs(panelId: panelId, refreshPorts: false) { | ||
| didMutate = true | ||
| didPruneStaleAgentRuntime = true | ||
| } | ||
|
austinywang marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| // Update bonsplit tab title only when this panel's title changed, and | ||
| // update the icon when the title-derived agent fallback changes. | ||
| if (didMutatePanelTitle || didMutateTitleDerivedAgent), | ||
| // update the icon when the current agent signal changes. | ||
| if (didMutatePanelTitle || didMutateTitleDerivedAgent || didPruneStaleAgentRuntime), | ||
| let tabId = surfaceIdFromPanelId(panelId), | ||
| let panel = panels[panelId], | ||
| let existing = bonsplitController.tab(tabId) { | ||
| let baseTitle = panelTitles[panelId] ?? panel.displayTitle | ||
| let resolvedTitle = resolvedPanelTitle(panelId: panelId, fallback: baseTitle) | ||
| let titleUpdate: String? = existing.title == resolvedTitle ? nil : resolvedTitle | ||
| let iconAssetUpdate: String?? = didMutateTitleDerivedAgent | ||
| let iconAssetUpdate: String?? = didMutateTitleDerivedAgent || didPruneStaleAgentRuntime | ||
|
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. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Add a test for the All three test cases transition the title to a different agent (or plain shell), so 🧪 Suggested additional test`@MainActor`
`@Test` func terminalTitleChangePrunesStaleAgentWithoutTitleDerivedKeyChange() throws {
let workspace = Workspace()
let panel = try `#require`(workspace.focusedTerminalPanel)
let tabId = try `#require`(workspace.surfaceIdFromPanelId(panel.id))
// Establish title-derived key as "codex" first
_ = workspace.updatePanelTitle(panelId: panel.id, title: "codex --yolo")
// Record a stale Claude PID
workspace.recordAgentPID(key: "claude_code.old-session", pid: 0, panelId: panel.id, refreshPorts: false)
// Stale Claude icon should be showing (live agent wins over title-derived)
`#expect`(workspace.terminalTabAgentIconAsset(forPanelId: panel.id) == "AgentIcons/Claude")
// Title changes but still maps to "codex" — title-derived key doesn't change
`#expect`(workspace.updatePanelTitle(panelId: panel.id, title: "codex --yolo --verbose"))
// Stale Claude pruned, icon should now show Codex from title-derived key
`#expect`(workspace.terminalTabAgentIconAsset(forPanelId: panel.id) == "AgentIcons/Codex")
`#expect`(workspace.bonsplitController.tab(tabId)?.iconAsset == "AgentIcons/Codex")
`#expect`(workspace.agentPIDs["claude_code.old-session"] == nil)
}🤖 Prompt for AI Agents |
||
| ? .some(terminalTabAgentIconAsset(forPanelId: panelId)) | ||
| : nil | ||
| bonsplitController.updateTab( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.