Repository navigation
fix(sidebar): update session labels in place - #547
Merged
Merged
Conversation
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
There was a problem hiding this comment.
🟢 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 toreloadItemfor 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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR A for #516: an animated OSC title on an un-renamed session changes only the row label, and
reloadChangedContentRowsanswered every content delta withreloadItem, 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 toreloadItem.a session row whose
RowContentdelta is the label alone now setsstringValueon 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 thereloadItempath. 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 indocs/backlog/flagged-noop-rename-strips-workspace-tail.md.Related to #516