This commit is contained in:
austinpower1258 2026-03-11 18:32:23 -07:00
parent 6849b83f8d
commit 5233874425
4 changed files with 233 additions and 10 deletions

View file

@ -1686,6 +1686,63 @@ final class Workspace: Identifiable, ObservableObject {
}
}
func resetSidebarContext(reason: String = "unspecified") {
statusEntries.removeAll()
logEntries.removeAll()
progress = nil
gitBranch = nil
panelGitBranches.removeAll()
pullRequest = nil
panelPullRequests.removeAll()
surfaceListeningPorts.removeAll()
listeningPorts.removeAll()
metadataBlocks.removeAll()
resetBrowserPanelsForContextChange(reason: reason)
}
func resetBrowserPanelsForContextChange(reason: String) {
let browserPanels = panels.values.compactMap { $0 as? BrowserPanel }
guard !browserPanels.isEmpty else { return }
#if DEBUG
dlog(
"workspace.contextReset.browserPanels workspace=\(id.uuidString.prefix(5)) " +
"reason=\(reason) count=\(browserPanels.count)"
)
#endif
for browserPanel in browserPanels {
browserPanel.resetForWorkspaceContextChange(reason: reason)
guard let tabId = surfaceIdFromPanelId(browserPanel.id),
let existing = bonsplitController.tab(tabId) else {
continue
}
let nextTitle = browserPanel.displayTitle
if panelTitles[browserPanel.id] != nextTitle {
panelTitles[browserPanel.id] = nextTitle
}
let resolvedTitle = resolvedPanelTitle(panelId: browserPanel.id, fallback: nextTitle)
let titleUpdate: String? = existing.title == resolvedTitle ? nil : resolvedTitle
let faviconUpdate: Data?? = existing.iconImageData == nil ? nil : .some(nil)
let loadingUpdate: Bool? = existing.isLoading ? false : nil
guard titleUpdate != nil || faviconUpdate != nil || loadingUpdate != nil else {
continue
}
bonsplitController.updateTab(
tabId,
title: titleUpdate,
iconImageData: faviconUpdate,
hasCustomTitle: panelCustomTitles[browserPanel.id] != nil,
isLoading: loadingUpdate
)
}
}
@discardableResult
func updatePanelTitle(panelId: UUID, title: String) -> Bool {
let trimmed = title.trimmingCharacters(in: .whitespacesAndNewlines)