Skip to content

fix(sidebar): update session labels in place - #547

Merged
umputun merged 3 commits into
masterfrom
sidebar-inplace-label
Sep 4, 2026
Merged

umputun merged 3 commits into
masterfrom
sidebar-inplace-label

Conversation

@umputun

@umputun umputun commented Sep 4, 2026

Copy link
Copy Markdown
Owner

PR A for #516: an animated OSC title on an un-renamed session changes only the row label, and reloadChangedContentRows answered every content delta with reloadItem, which tears the cell down and rebuilds it through the delegate on each tick. The profile from @dimonb in #516 attributed 2.61 of the 2.80 ms per sidebar update to reloadItem.

a session row whose RowContent delta is the label alone now sets stringValue on its live cell and schedules layout, so the truncation tooltip re-evaluates. Workspace rows, every other delta, and a row with no live cell (collapsed or scrolled off) keep the reloadItem path. The rename guard is unchanged.

tests assert that title ticks skip the cell builder, preserve the blink animation, and refresh the truncation tooltip.

B, the window title as a dependency of WindowContentView.body, is a separate PR. A pre-existing flagged-mode rename defect found on the way is recorded in docs/backlog/flagged-noop-rename-strips-workspace-tail.md.

Related to #516

an OSC title tick on an un-renamed session changes only the row label, and
reloadChangedContentRows answered it with reloadItem, which tears the cell down
and rebuilds it through the delegate on every frame. The reporter's profile on
#516 put that reload at most of the sidebar's per-tick cost.

a session row whose RowContent delta is the label alone now sets stringValue
on its live cell and schedules layout for the truncation tooltip. Workspace
rows, every other delta, and a row with no live cell (collapsed or scrolled
off) keep the reloadItem path.

Related to #516
Copilot AI lite review requested due to automatic review settings September 4, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The in-place relabel path is narrowly scoped, preserves the existing reload fallback, and is backed by hosted tests covering rebuild avoidance, animation continuity, and tooltip refresh.

Pull request overview

This PR reduces sidebar CPU churn caused by frequent OSC title updates by avoiding NSOutlineView.reloadItem for session rows whose only change is the label, updating the live cell’s stringValue instead while preserving rename-guard behavior and ensuring tooltip truncation stays correct.

Changes:

  • Add a label-only fast path in WorkspaceSidebar.Coordinator.reloadChangedContentRows() that relabels an on-screen session cell in place and schedules layout (tooltip refresh), falling back to reloadItem for all other deltas.
  • Add hosted tests asserting title ticks don’t trigger cell rebuilds, preserve the blink animation, and refresh the truncation tooltip.
  • Record a separate, pre-existing flagged-mode rename edge case in docs/backlog/.
File summaries
File Description
agterm/Views/WorkspaceSidebar.swift Implements label-only in-place relabeling for visible session rows, otherwise keeps reloadItem behavior.
agtermTests/SidebarStatusBlinkTests.swift Adds a delegate wrapper to count cell builds and verifies title ticks don’t rebuild cells or restart blink animations.
agtermTests/SidebarRowViewsTests.swift Adds tooltip-refresh coverage for in-place relabeling on the live session cell.
docs/backlog/flagged-noop-rename-strips-workspace-tail.md Documents a related, pre-existing flagged-mode rename no-op defect without changing app behavior.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@umputun
umputun merged commit a8bbaa5 into master Sep 4, 2026
9 checks passed
@umputun
umputun deleted the sidebar-inplace-label branch September 4, 2026 22:09
umputun added a commit that referenced this pull request Sep 4, 2026
…tView.body (#548)

PR B for #516, after #547. `WindowContentView.body` read the active session's `displayName` twice, for the OS title token and for the visible title row, so every OSC title tick invalidated the whole body and re-ran SwiftUI's graph and layout for the window. `WindowAccessor.updateNSView` then ran the full `WindowAppearance.sync` when only `NSWindow.title` had changed.

two child views now own those reads. `WindowTitleSync` resolves the OS title in its own body and hosts `WindowAccessor`; `TitlebarLabel` resolves `TitlebarComposition` for the visible row, and the zoom titlebar reuses it. The parent passes the store and ids and no title. `WindowAccessor` writes `window.title` on a token change and keeps the blend on attach, key, main, fullscreen, appearance and accessibility changes, which already carry every other blend input. The custom window name lookup moved into `WindowLibrary` next to `windowName(for:)`, and the dashboard title uses it.

tests: hosted, a `TitleProbeView` title write leaves a separator sentinel the full blend would reset, a title set before attach survives attachment, and `WindowTitleSync` hosted in `NSHostingView` follows an OSC title, a session rename and a window rename to `NSWindow.title`. Host-free, the `customWindowName(for:)` cases.

profile, Time Profiler, Debug builds of a8bbaa5 and this branch, isolated state, sidebar hidden, one session printing numbered OSC 2 titles at about 10 Hz, two recordings of about 20 s each, main thread only. Values are inclusive main-thread sample weight in ms:

| symbol | a8bbaa5 | this branch |
| --- | --- | --- |
| `WindowContentView.body.getter` | 212 | 0 |
| `WindowTitleSync.body` / `TitlebarLabel.body` | absent | 6 / 28 |
| `WindowAppearance.sync` | 70 | 0 |
| `-[NSWindow _dosetTitle:andDefeatWrap:]` | 187 | 213 |
| `GraphHost.flushTransactions` | 1086 | 539 |
| main thread, all samples | 1774 | 978 |

these are sample weights over two separately timed recordings, not update counts and not a per-tick or total-CPU saving: the baseline tick count was not recorded, so the two workloads are not matched. The SwiftUI Instruments template hung on finalization here, so there is no SwiftUI-lane update count; the parent body had zero samples in the patched recording while the two child bodies and the title write were present. @dimonb, could you rerun your harness against this patch to measure the per-tick change?

Fix #516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants