8000 Fix Across-worktrees participant badge lifecycle by rore · Pull Request #37 · rore/minimap · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ The optional Minimap participant panel is read-only. With a validated loopback `
Across worktrees is a separate read-only board projection. Its `GET /api/worktree-workspace` snapshot includes one bounded participant-count batch for at most 200 unambiguous logical features across versions, including completed versions so In play can be evaluated without a second board scan. The UI still shows badges only where the current view permits them. Associations are feature-wide, never evidence that a particular checkout version is active. Independent features sharing an NFC-equivalent item ID receive no inferred count or participant detail; a partial/unknown result is not zero.

The provisional `?openedOnly=1` snapshot skips this batch and participant-detail reads until the full scan resolves feature identity. Its session status is loading/unknown, not zero, and feature totals and In play cover only the opened checkout. A failed full scan leaves this incomplete view usable with Refresh retry.

Across-worktrees counts stay with that workspace snapshot when the page is hidden or Spec sessions is opened. Returning to the board does not trigger per-card lookups; Refresh replaces the snapshot, and changing repo or source scope discards it.
4 changes: 4 additions & 0 deletions package/minimap/skills/minimap-roadmap/runtime/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4701,6 +4701,10 @@ function invalidateBoardPresence({ keepCounts = false } = {}) {
boardParticipantController?.abort();
boardParticipantController = null;
boardParticipantGeneration += 1;
// Across counts belong to the workspace snapshot, not the visibility poller.
// Preserve them while paused; a repo/source change still discards them.
if (state.worktreeMode === "across" && state.workspaceScope?.mode === "across"
&& state.workspaceScope.repoPath === state.repoPath) return;
if (!keepCounts) boardParticipantCounts = new Map();
boardParticipantIncludeCompleted = null;
boardParticipantStatus = "idle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The roadmap source menu uses `GET /api/worktree-sources` only for lightweight di

## Shared runtime replacement

The shared roadmap UI progressively opens Across worktrees: `GET /api/worktree-workspace?openedOnly=1` returns a guarded opened-checkout-only snapshot while the full aggregate runs. Exactly one `openedOnly=1` is accepted; invalid or repeated values return 400. The provisional response sets `provisional: true`, `partial: true`, and `coverage.pending: true`. Its feature totals, In play, and participant coverage are explicitly incomplete. No participant lookup runs until full feature identity is resolved. Refresh retains the last board and editor during loading; failure retains usable provisional or last-known content with retry. This does not change spec-session APIs or authorize writes across checkouts.
The shared roadmap UI progressively opens Across worktrees: `GET /api/worktree-workspace?openedOnly=1` returns a guarded opened-checkout-only snapshot while the full aggregate runs. Exactly one `openedOnly=1` is accepted; invalid or repeated values return 400. The provisional response sets `provisional: true`, `partial: true`, and `coverage.pending: true`. Its feature totals, In play, and participant coverage are explicitly incomplete. No participant lookup runs until full feature identity is resolved. Refresh retains the last board and editor during loading; failure retains usable provisional or last-known content with retry. Across-worktrees participant counts remain part of that snapshot while the page is hidden or Spec sessions is open; Refresh replaces them, and changing repo or source scope discards them. This does not change spec-session APIs or authorize writes across checkouts.

Health reports `runtime: { version, apiCompatibility, sourcePath }` and live `pid`. API compatibility is integer 1; it changes only for incompatible server API changes, independently of package release versions.

Expand Down
4 changes: 4 additions & 0 deletions package/minimap/skills/minimap-spec-review/runtime/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4701,6 +4701,10 @@ function invalidateBoardPresence({ keepCounts = false } = {}) {
boardParticipantController?.abort();
boardParticipantController = null;
boardParticipantGeneration += 1;
// Across counts belong to the workspace snapshot, not the visibility poller.
// Preserve them while paused; a repo/source change still discards them.
if (state.worktreeMode === "across" && state.workspaceScope?.mode === "across"
&& state.workspaceScope.repoPath === state.repoPath) return;
if (!keepCounts) boardParticipantCounts = new Map();
boardParticipantIncludeCompleted = null;
boardParticipantStatus = "idle";
Expand Down
4 changes: 4 additions & 0 deletions package/minimap/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4701,6 +4701,10 @@ function invalidateBoardPresence({ keepCounts = false } = {}) {
boardParticipantController?.abort();
boardParticipantController = null;
boardParticipantGeneration += 1;
// Across counts belong to the workspace snapshot, not the visibility poller.
// Preserve them while paused; a repo/source change still discards them.
if (state.worktreeMode === "across" && state.workspaceScope?.mode === "across"
&& state.workspaceScope.repoPath === state.repoPath) return;
if (!keepCounts) boardParticipantCounts = new Map();
boardParticipantIncludeCompleted = null;
boardParticipantStatus = "idle";
Expand Down
135 changes: 135 additions & 0 deletions playwright/worktree-ui.spec.js
10000
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,138 @@ test("independent same-ID features do not acquire participant detail from each o
await fs.rm(owned, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
}
});

test("Across participant badges survive view invalidation and stay scoped to their workspace snapshot", async ({ page }, testInfo) => {
test.setTimeout(60_000);
const { owned, root, sibling } = await fixture(64);
const other = await fixture(2);
const completedPath = path.join(sibling, "roadmap", "features", "large-01.md");
await fs.writeFile(completedPath, (await fs.readFile(completedPath, "utf8")).replace("status: in-progress", "status: done"));
const aggregateReads = [];
const boardCountReads = [];
const participantReads = [];
let injectCounts = true;
let recentCount = 1;
page.on("request", (request) => {
if (/\/api\/worktree-workspace(?:\?|$)/.test(request.url())) aggregateReads.push(request.url());
if (/\/api\/(?:source\/)?board\/participant-counts(?:\?|$)/.test(request.url())) boardCountReads.push(request.url());
if (/\/api\/(?:source\/)?items\/[^/]+\/participants(?:\?|$)/.test(request.url())) participantReads.push(request.url());
});
await page.route(/\/api\/worktree-workspace(?:\?|$)/, async (route) => {
const response = await route.fetch();
const payload = await response.json();
const openedOnly = new URL(route.request().url()).searchParams.get("openedOnly") === "1";
if (injectCounts && !openedOnly && !payload.provisional && Array.isArray(payload.features)) {
const featureKey = (id) => payload.features.find((feature) => feature.id === id)?.key;
const rows = [
{ id: "large-02", recentParticipantCount: recentCount, dormantParticipantCount: 0 },
{ id: "large-03", recentParticipantCount: 0, dormantParticipantCount: 2 },
{ id: "large-04", recentParticipantCount: 1, dormantParticipantCount: 1 },
{ id: "large-05", recentParticipantCount: 0, dormantParticipantCount: 0 },
// Stale/over-inclusive data must not render a completed feature badge.
{ id: "large-01", recentParticipantCount: 3, dormantParticipantCount: 0 },
].map(({ id, ...counts }) => ({
featureKey: featureKey(id),
participantCount: counts.recentParticipantCount + counts.dormantParticipantCount,
...counts,
}));
payload.participantCounts = {
status: "ok", counts: rows, partial: true,
asOf: "2026-09-24T08:30:00.000Z", recentSeconds: 86400,
};
}
await route.fulfill({ response, json: payload });
});

try {
await page.goto(`/#repo=${encodeURIComponent(root)}&sources=across`);
const badges = page.locator(".board-item-participants:visible");
await expect(badges).toContainText(["Recent 1", "Dormant 2", "Recent 1", "Dormant 1"]);
const completedBadge = page.getByRole("button", { name: /Open large-01/ }).locator(".board-item-participants").first();
await expect(page.getByRole("button", { name: /Open large-05/ }).locator(".board-item-participants")).toHaveCount(0);
await expect(page.getByRole("button", { name: /Open large-06/ }).locator(".board-item-participants")).toHaveCount(0);
await expect(completedBadge).toHaveCount(0);
await expect(page.locator("#board-participant-status")).toContainText(/partial/i);
const listScreenshotCard = page.getByRole("button", { name: /Open large-02/ }).first();
await listScreenshotCard.scrollIntoViewIfNeeded();
await page.screenshot({ path: testInfo.outputPath("across-participant-badges-list-desktop.png") });
await page.setViewportSize({ width: 390, height: 840 });
await listScreenshotCard.scrollIntoViewIfNeeded();
await page.screenshot({ path: testInfo.outputPath("across-participant-badges-list-390.png") });
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBeLessThanOrEqual(2);
await page.setViewportSize({ width: 1440, height: 900 });
const initialReads = aggregateReads.length;
const initialDetailReads = participantReads.length;
const initialBoardCountReads = boardCountReads.length;
expect(initialReads).toBeGreaterThan(0);
await page.locator("#board-focus-in-play").click();
await expect(page.locator("#board-focus-in-play")).toHaveAttribute("aria-pressed", "true");
await expect(completedBadge).toHaveText("Recent 3");
await expect(page.locator(".board-item-participants:visible")).toHaveCount(5);
await page.locator("#board-focus-in-play").click();
await expect(page.locator("#board-focus-in-play")).toHaveAttribute("aria-pressed", "false");
await expect(completedBadge).toHaveCount(0);
await expect(page.locator(".board-item-participants:visible")).toHaveCount(4);

for (const layout of ["list", "columns"]) {
if (layout === "columns") {
await page.locator("#board-layout-columns").click();
await expect(page.locator(".board-item-participants:visible")).toHaveCount(4);
const columnsScreenshotCard = page.getByRole("button", { name: /Open large-02/ }).first();
await columnsScreenshotCard.scrollIntoViewIfNeeded();
await page.screenshot({ path: testInfo.outputPath("across-participant-badges-columns-desktop.png") });
await page.setViewportSize({ width: 390, height: 840 });
await columnsScreenshotCard.scrollIntoViewIfNeeded();
await page.screenshot({ path: testInfo.outputPath("across-participant-badges-columns-390.png") });
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBeLessThanOrEqual(2);
await page.setViewportSize({ width: 1440, height: 900 });
}
await page.evaluate(() => {
Object.defineProperty(document, "visibilityState", { configurable: true, value: "hidden" });
document.dispatchEvent(new Event("visibilitychange"));
});
await page.evaluate(() => {
Object.defineProperty(document, "visibilityState", { configurable: true, value: "visible" });
document.dispatchEvent(new Event("visibilitychange"));
});
await expect(page.locator(".board-item-participants:visible")).toHaveCount(4);
await expect(page.locator("#board-participant-status")).toContainText(/partial/i);
expect(aggregateReads).toHaveLength(initialReads);
expect(boardCountReads).toHaveLength(initialBoardCountReads);
expect(participantReads).toHaveLength(initialDetailReads);

await page.locator("#spec-mode-button").click();
await expect(page.locator("#spec-workbench")).toBeVisible();
await page.locator("#roadmap-mode-button").click();
await expect(page.locator("#spec-workbench")).toBeHidden();
await expect(page.locator(".board-item-participants:visible")).toHaveCount(4);
expect(aggregateReads).toHaveLength(initialReads);
expect(boardCountReads).toHaveLength(initialBoardCountReads);
expect(participantReads).toHaveLength(initialDetailReads);
}

await page.locator("#board-source-toggle").click();
await page.locator('#board-source-menu [data-source-choice="this"]').click();
await expect(page.locator(".board-item-participants:visible")).toHaveCount(0);
await page.locator("#board-source-toggle").click();
await page.locator('#board-source-menu [data-source-choice="across"]').click();
await expect(page.locator(".board-item-participants:visible")).toHaveCount(4);

recentCount = 2;
await page.locator("#refresh-button").click();
const large02Card = page.locator(".board-column-card-main").filter({ hasText: "large-02" }).first();
await expect(large02Card.locator(".board-item-participants").first()).toHaveText("Recent 2");

injectCounts = false;
await page.evaluate((hash) => { window.location.hash = hash; }, `repo=${encodeURIComponent(other.root)}&sources=across`);
await expect(page.locator("#board-source-toggle")).toContainText("Across worktrees");
await expect(page.locator("#board-source-status-summary")).toContainText("3 features");
const otherLarge02Card = page.locator(".board-item:visible, .board-column-card-main:visible").filter({ hasText: "large-02" }).first();
await expect(otherLarge02Card).toBeVisible();
await expect(otherLarge02Card.locator(".board-item-participants")).toHaveCount(0);
await expect(page.locator("#board-participant-status")).not.toContainText(/partial/i);
} finally {
await fs.rm(owned, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
await fs.rm(other.owned, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
}
});
1 change: 1 addition & 0 deletions roadmap/board.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- idea-timeline-view

# Done
- restore-worktree-participant-badges
- polish-worktree-view-usability
- add-worktree-aware-roadmap-view
- add-server-lifecycle-logging
Expand Down
30 changes: 30 additions & 0 deletions roadmap/features/restore-worktree-participant-badges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: restore-worktree-participant-badges
title: Restore participant badges on the combined worktree board
status: done
priority: high
commitment: committed
---

## Summary

Investigate and correct a board/detail participant mismatch after the worktree changes. User screenshots show a settled Across worktrees card without a badge while its item panel reports Recent 1.

## Scope

Trace aggregate count lookup, logical feature identity, and card rendering. Preserve batched queries, lifecycle semantics, ambiguous-identity protection, and progressive loading. Do not infer that missing or partial counts mean zero, and do not fetch participants separately for every card.

## Acceptance

- List and Columns show recent, dormant, and mixed counts for eligible features after full loading and refresh.
- Detail and board counts use consistent feature identity; no counts leak between ambiguous same-ID features.
- Provisional, unavailable, partial, completed-item, and In play behavior remain correct.
- Generic regression tests and actual rendered screenshots demonstrate the fix; live project verification is read-only.

## Coordination

Root cause: full aggregate and detail both reported Recent 1, but a hidden-to-visible tab lifecycle transition cleared board counts. Across mode excludes the regular count poller, so the badge did not recover. PR #37 retains the aggregate count snapshot during same-scope lifecycle pauses and clears it on scope changes, preserving cancellation and generation guards. Counts remain observations from the last workspace snapshot; Refresh updates them.

Implementation accepted at 29c2882: 358 Node tests passed with 2 expected Windows skips, 39 related browser tests passed, and the strengthened final regression passed separately. Independent developer review found no correctness issues. Manager reviewed the guard and scope-changing callers and inspected actual Columns desktop, List 760px, and Columns 390px screenshots. Developer reproduced the failure by removing only the guard and verified live dictation_app read-only hide/show and spec round trips with no browser errors or writes. Final CI and packaged deployment are release gates; this entry records accepted implementation, not proof of a running server version.

Minimap-manager owns canonical roadmap, acceptance, and delivery. Minimap-dev accepted on 2026-10-01 through the authorized app fallback after Relay claim ordering prevented a reply to the pending assignment. Implementation starts from main 5caac96 in an isolated branch, with no shared-server restart or live-project writes. Root cause is not yet established. The existing card renderer still calls the participant badge helper, so removal of the markup alone is not established.
Loading
0