Keep the Review view current on activation and agent writes - #19
Open
adamhulme wants to merge 3 commits into
Open
Keep the Review view current on activation and agent writes#19adamhulme wants to merge 3 commits into
adamhulme wants to merge 3 commits into
Conversation
The visibility subscription for lookout.review was registered inside context.subscriptions well after createTreeView, past an await. A freshly created tree view reports visible === false until it renders, so the render event landed in that gap with no listener attached and was lost. The cached flag then stayed false forever, and initialize() skipped both refresh() and startWorktreePolling() -- leaving Workspace Changes, Problems, Running, and Plans & Docs empty and unpolled until the user manually switched containers. Subscribe synchronously after creation, before sampling visible and before any await. Also populate once from getChildren, which is the one signal that cannot be missed: VS Code only requests children when the view genuinely renders. That covers both render-then-initialize and initialize-then-render without doing Git work for a view the user never opens. The existing extension-host test calls reviewTree.refresh() directly, so it bypassed the population path entirely. Guard the ordering invariant statically instead; the new test fails against the previous wiring. Co-Authored-By: Claude <noreply@anthropic.com>
loadWorktreeChanges grouped sessions from history(), which includes closed ones, then anchored each worktree on the earliest attached session. A closed session holds no terminal and is attached to nothing, so a week-old session could dictate a live context's baseline and start time. Observed with three open agents on one branch alongside a closed session from six days earlier whose baseline branch was main. The group reported "branch changed; the captured diff baseline is stale" permanently, diffed from the wrong commit so the change count was inflated, and -- because plan eligibility is mtime >= startedAt -- listed documents no agent had produced. The linked-worktree path already filtered to open sessions; only the direct path did not. Extract the choice into a pure reviewAnchor module so the invariant is unit-testable, and use it for the baseline, start time, and attached labels. D5's stability intent is preserved: the earliest OPEN session still anchors, so already-reviewed changes do not disappear as newer sessions attach. The full list remains a fallback so a context mid-teardown renders rather than vanishing. Co-Authored-By: Claude <noreply@anthropic.com>
The previous overview image predated several shipped changes: it showed a History view, an Other Projects group, and six evidence rows above Workspace Changes. It also appeared only in the walkthrough, never in the README. Capture the current sidebar and add it under "Lookout at a glance", where the surrounding text already describes exactly what the image shows. The walkthrough media in package.json references the same path, so all three steps pick this up without further change. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Two Review-view correctness fixes, both surfaced while preparing the 1.0.0 release. Follows #18, which landed the disk-write invalidation.
f1e604d— Populate the Review view on first render. The view could activate completely dead: empty groups and no worktree polling, recoverable only by manually switching sidebar containers.70d49f2— Anchor Review contexts on the earliest open agent. A closed session could impose a stale baseline branch, an inflated change count, and unrelated documents as agent artifacts.Bug 1: lost visibility event
onDidChangeVisibilityforlookout.reviewwas registered inside thecontext.subscriptionsarray, ~60 lines aftercreateTreeViewand pastawait coordination.initialize(). A freshly created tree view reportsvisible === falseuntil it renders, so the render event landed in that unlistened gap and was lost permanently. The cached flag stayedfalse, andinitialize()skipped bothrefresh()andstartWorktreePolling().Observed as
Workspace Changes 0showing the field-initializer placeholder. That placeholder is only reachable whenapplyWorktreeChanges()has never run — had it run with no baselines the message would read "No open agents have a Git baseline", and with baselines present the group renders children either way.Fix: subscribe synchronously after
createTreeView, before sampling.visibleand before anyawait. Also populate once fromgetChildren, the one signal that cannot be missed, since VS Code only requests children when the view genuinely renders. That covers both orderings while still doing no Git work for a view the user never opens.Only the Review view was affected;
lookout.sessionsandlookout.usagenever callsetVisible.Bug 2: closed sessions anchoring live contexts
loadWorktreeChangesgrouped sessions fromhistory(), which includes closed ones, then anchored each worktree on the earliest attached session. A closed session holds no terminal and is attached to nothing.Observed with three open agents on one branch alongside a closed session from six days earlier whose baseline branch was
main. The group reported "branch changed; the captured diff baseline is stale" permanently, diffed from the wrong commit so the change count was inflated, and — because plan eligibility ismtime >= startedAt— listed documents no agent had produced.The linked-worktree path already filtered to open sessions; only the direct path did not. Fix extracts the choice into a pure
reviewAnchormodule so the invariant is unit-testable, and uses it for the baseline, start time, and attached labels.D5's stability intent is preserved: the earliest open session still anchors, so already-reviewed changes do not disappear as newer sessions attach. The full list remains a fallback so a context mid-teardown renders rather than vanishing.
Testing
npm run check— 226 fast tests pass, lint and repository-artifact policy greenxvfb-run -a npm run test:integration— 14 extension-host tests passtest/reviewViewActivation.test.tsverified to fail against the previous wiring (sampling .visible must not precede the visibility subscription), so it is a real guard rather than a tautologytest/reviewAnchor.test.tscovers the anchor invariant directly, including the teardown fallbackThe existing extension-host test calls
api.reviewTree.refresh()directly, which is why neither bug was caught — hence the added guards.🤖 Generated with Claude Code