Repository navigation
A hook's message rebuilds the sidebar once, finds PRs and rows by key, and Attention is worked out once per change - #288
Merged
Merged
Conversation
…, and Attention is worked out once per change Every working-state hook commits its session, and each commit rebuilt the sidebar once per domain part it wrote (sessions, GitHub, PR details, feedback, the pilot's log), each rebuild O(sessions² × PRs). Nothing a user sees changes; each step is now cheaper or done once. - **One rebuild per commit.** The didSets of `sessions`, `github`, `pullDetails`, `feedback` and `pilotLog` ask a `Coalesced` rebuild (HeedCore). Outside a commit it runs at once, as before; `commit` and `replace(with:)` write every part in a batch and rebuild once at its end, then update the Dock/menu bar and tell the notifier which sessions changed state, in the same order as before. - **The next tool of a working turn.** `Session.changedOnlyActivity(from:)` says a commit changed only what an agent is doing (activity line, lastActivity, the reason of an unchanged state). Such a commit skips the notices that cannot fire on it: ledger, naming, turn ends, audit of new sessions and goal attach. Everything time-based (session panel, goal PRs) and every reader of `sessions` still see the new values. - **Run hooks.** A run's hook rebuilds the list only when the run's state changed, not on every tool call. - **PRs by ref.** `GitHubState.pull(_:)` reads an index kept with `pulls` (still the first match). The index takes no part in equality, hashing or the cache. - **Pilot state once per rebuild.** Whether a PR has a session reads a set kept with `sessions`; one rebuild works out each PR's and each session's pilot state once (the rows, sizes and close checks asked again). - **Rows by id.** `SessionList.index(of:)` and `pinIndex(of:)` replace `firstIndex(of:)` (full `Session` equality) in the sidebar and the rail; the list sorts by size asking each size once and drops done sessions by id. - **Attention.** Its entries and listing are kept (`Derived`) until something they read changes, or for a second (they read the clock), so the badge, counts, coverage line and list share one computation. The rules are parsed when `[attention] rules` changes, not on every read. - **Presence.** A hook writes `agentPresence` only when it changes which panes run an agent. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Part (a) of the code-health performance round (plan PR 11): the hook path, the sidebar, Attention. Screen reading, startup, GitHub sync and telemetry, and Audit/ExternalText/OriginKeeper come in their own PRs.
Every working-state hook commits its session. Each commit rebuilt the sidebar once per domain part it wrote (sessions, GitHub, PR details, feedback, pilot log), each rebuild O(sessions² × PRs). What the user sees does not change; each step is now cheaper or done once.
sessions,github,pullDetails,feedbackandpilotLogask aCoalescedrebuild (HeedCore). Outside a commit it runs at once, as before.commitandreplace(with:)write every part in a batch and rebuild once at the end, then update the Dock and menu bar and note state changes, in the same order as before.Session.changedOnlyActivity(from:)detects a commit that changed only what an agent is doing (the activity line, lastActivity, the reason of an unchanged state). Such a commit skips the five notices that read only other fields and so cannot fire on it: ledger, naming, turn ends, audit of new sessions, goal attach. The time-based notices (session panel, goal PRs) still run. Every reader ofsessionsstill sees the new values.GitHubState.pull(_:)reads an index kept withpullsand still returns the first match. The index takes no part in equality, hashing or the cache.sessions. Within one rebuild, each PR's and each session's pilot state is worked out once and reused.SessionList.index(of:)andpinIndex(of:)replacefirstIndex(of:), which compared wholeSessionvalues, in the sidebar and the rail. The size sort asks each session's size once, and done sessions are dropped by id.Derived, HeedApp) until something they read changes (withObservationTracking), or for at most one second because they read the clock. The badge, counts, coverage line and list share one computation. A per-value observed counter makes readers of the kept value redraw as before.[attention] rulesare parsed when they change.agentPresenceonly when it changes which panes run an agent.Deliberate deviations from the audit's suggestions
Sessioninto a separate store.lastActivityandactivityhave about 57 readers (sweep, ledger staleness, permission asks, away summary, control socket, swarm stuck), and a store that lags would change what they see. Instead, an activity-only commit stays exact and skips the work that cannot apply to it.rebuildList. Several of them (watch labels, close readiness, pilot status) depend on runs, helpers and the clock, which do not trigger a rebuild, so precomputed values would go stale. The rows instead call helpers that are now cheap: O(1) index lookups and the PR index.Verification
swift build. Targeted tests pass:HookPathTests(new, 14 tests), DomainMirror, SessionsView, GitHub, QuietHours, ResumeBanner, AttentionListing, SettingsLayout (96 tests).mise run fmtandmise run lintare clean.Coalesced.requestrun immediately, dropping thepullsindex didSet, dropping the rules didSet, dropping the state comparison inchangedOnlyActivity, and makingAgentPresence.changesalways true each made the matching tests fail. The size-memo mutation ran in the same batch, but its result line was cut from the output, so it is unconfirmed.DomainMirrorTestsnow readsreplaceParts(with:)andwrite(_:over:changed:), where the parts are written now.Not done / untested
Tests/HeedCoreTests/Bench/SidebarBench.swiftis added (200 sessions sorted by size; 600 PR lookups among 2,000), but the release builds did not finish on a machine at load average about 200, so there are no before/after numbers yet. Runmise run bench(filterSidebarBench, and CoreBench'ssessionList) on main and on this branch.mise run tutor-checkand the app itself: not run.Derived's observation-driven invalidation is untested at runtime: there is no HeedApp test target.🤖 Generated with Claude Code