Skip to content

Keep the Review view current on activation and agent writes - #19

Open
adamhulme wants to merge 3 commits into
mainfrom
agent/review-view-first-render
Open

Keep the Review view current on activation and agent writes#19
adamhulme wants to merge 3 commits into
mainfrom
agent/review-view-first-render

Conversation

@adamhulme

Copy link
Copy Markdown
Collaborator

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

onDidChangeVisibility for lookout.review was registered inside the context.subscriptions array, ~60 lines after createTreeView and past await coordination.initialize(). A freshly created tree view reports visible === false until it renders, so the render event landed in that unlistened gap and was lost permanently. The cached flag stayed false, and initialize() skipped both refresh() and startWorktreePolling().

Observed as Workspace Changes 0 showing the field-initializer placeholder. That placeholder is only reachable when applyWorktreeChanges() 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 .visible and before any await. Also populate once from getChildren, 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.sessions and lookout.usage never call setVisible.

Bug 2: closed sessions anchoring live contexts

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.

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. Fix extracts the choice into a pure reviewAnchor module 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 green
  • xvfb-run -a npm run test:integration — 14 extension-host tests pass
  • test/reviewViewActivation.test.ts verified to fail against the previous wiring (sampling .visible must not precede the visibility subscription), so it is a real guard rather than a tautology
  • test/reviewAnchor.test.ts covers the anchor invariant directly, including the teardown fallback

The existing extension-host test calls api.reviewTree.refresh() directly, which is why neither bug was caught — hence the added guards.

🤖 Generated with Claude Code

adamhulme and others added 3 commits July 24, 2026 20:26
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>
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.

1 participant