From 01a5b40d0f6e32d02e7b29a3e2d615b9e513d73d Mon Sep 17 00:00:00 2001 From: dafuga Date: Sun, 29 Nov 2026 18:50:25 +0000 Subject: [PATCH 1/5] fix: reproduce the canary failure on the Needs you board --- .../tests/e2e/hub-home-board-waiting.spec.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts index d4528808d7d..e4f6dd07344 100644 --- a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts +++ b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts @@ -1,6 +1,11 @@ import { expect, test, type Page } from '../../../../test/support/browserTest'; import { cardPanel, column, needCards, showColumn } from './hub-home-click-through'; import { boardHome, noSidewaysScroll, sizes } from './hub-home-board-page'; +import { captureNeedsYou } from './hub-home-capture'; +import { + pressOptionScript, + rowLabelsScript +} from '../../../../scripts/needs-you-canary/hubRowScripts'; /** The Needs you and Waiting columns, drawn from made-up records a synthetic linked Mac answers with. */ test.setTimeout(60000); @@ -12,7 +17,7 @@ for (const size of ['desktop', 'phone'] as const) test(`Waiting says what it waits on, and only Needs you says Urgent (${size})`, async ({ page }) => { - await boardHome(page, size); + const chats = await boardHome(page, size); await showColumn(page, 'Needs you'); await expect(column(page, 'Needs you').locator('.hb-urgent')).toHaveText(['Urgent']); await showColumn(page, 'Waiting'); @@ -27,6 +32,20 @@ for (const size of ['desktop', 'phone'] as const) await expect(panel).toContainText('Waiting on the sample account from [ab12cd]'); await expect(panel).toContainText('Draft is ready; waiting on the sample account'); await expect(panel).not.toContainText('Blocked'); + const question = 'Which layout should the catalogue open with?'; + expect(await page.evaluate(rowLabelsScript('the sample account'))).toBeNull(); + expect(await page.evaluate(pressOptionScript(question, 'List'))).toBe(false); + await panel.getByRole('button', { name: 'Close viewer' }).click(); + await showColumn(page, 'Needs you'); + const readChoices = () => page.evaluate(rowLabelsScript(question)); + await readChoices(); + await captureNeedsYou(page, `canary-board-${size}`); + await expect.poll(readChoices).toContain('List'); + expect(await page.evaluate(pressOptionScript('the sample account', 'List'))).toBe(false); + expect(await page.evaluate(pressOptionScript(question, 'List'))).toBe(true); + await expect + .poll(() => chats) + .toMatchObject([{ kind: 'answer', itemId: 'catalogue', option: 2, text: 'List' }]); await noSidewaysScroll(page, sizes[size].width); }); From b26cc694d8acd231bb0b3dfce2740c04b2976cd1 Mon Sep 17 00:00:00 2001 From: dafuga Date: Sun, 29 Nov 2026 18:55:53 +0000 Subject: [PATCH 2/5] fix: answer the web canary from the Needs you board --- scripts/needs-you-canary/hubRowScripts.ts | 36 ++++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/needs-you-canary/hubRowScripts.ts b/scripts/needs-you-canary/hubRowScripts.ts index 6d6dfed3c07..dcf5a463f85 100644 --- a/scripts/needs-you-canary/hubRowScripts.ts +++ b/scripts/needs-you-canary/hubRowScripts.ts @@ -1,21 +1,35 @@ // @harness-uid u_k2msamt5dy -/** - * Page expressions against Hub Home's "Blocked - needs you" rows. A row is found by the list and - * its question, so a row without buttons is still found and reported as having none. - */ -const rowWith = (marker: string) => - `[...document.querySelectorAll('.hh-needs-list > *')].find((row) => row.querySelector('.hh-needs-question')?.textContent.includes(${JSON.stringify(marker)}))`; -const choices = "[...row.querySelectorAll('.hh-choices .hh-choice')]"; +const cards = 'li.hb-card[data-needs]'; +const details = 'dialog[open] [data-harness-component="board-detail"]'; +const marked = (selector: string, question: string, marker: string) => + `[...document.querySelectorAll(${JSON.stringify(selector)})].find((element) => + element.querySelector(${JSON.stringify(question)})?.textContent.includes(${JSON.stringify(marker)}))`; +const detailWith = (marker: string) => marked(details, '.hh-ask-question', marker); +const choices = "[...detail.querySelectorAll('.hh-choices button.hh-choice')]"; const labelOf = "choice.querySelector('strong')?.textContent.trim()"; -/** The option labels on the row, or null while there is no such row. */ +/** Open the matching Needs you card, then read its choices on the next poll. */ export function rowLabelsScript(marker: string): string { - return `(() => { const row = ${rowWith(marker)}; return row ? ${choices}.map((choice) => ${labelOf}) : null; })()`; + return `(() => { + const detail = ${detailWith(marker)}; + if (detail) return ${choices}.map((choice) => ${labelOf}); + const card = ${marked(cards, '.hb-line', marker)}; + if (!card) return null; + card.querySelector('button[id^="hh-ask-"]')?.click(); + return []; + })()`; } -/** Press one option on the row. False when it is missing or disabled. */ +/** Press one option in the open detail for this exact ask. */ export function pressOptionScript(marker: string, label: string): string { - return `(() => { const row = ${rowWith(marker)}; if (!row) return false; const button = ${choices}.find((choice) => ${labelOf} === ${JSON.stringify(label)}); if (!button || button.disabled) return false; button.click(); return true; })()`; + return `(() => { + const detail = ${detailWith(marker)}; + if (!detail) return false; + const button = ${choices}.find((choice) => ${labelOf} === ${JSON.stringify(label)}); + if (!button || button.disabled) return false; + button.click(); + return true; + })()`; } /** One yes or no. The account itself never leaves the page. */ From 272abe5e1b69afac94b70a699385bb893973bec5 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 13:21:49 +0000 Subject: [PATCH 3/5] fix: reproduce missed canary in a long Needs you column --- packages/hub/tests/e2e/hub-home-board-page.ts | 31 +++++++++++++++++-- .../tests/e2e/hub-home-board-waiting.spec.ts | 26 +++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/packages/hub/tests/e2e/hub-home-board-page.ts b/packages/hub/tests/e2e/hub-home-board-page.ts index 390e52ae98c..475cbac738a 100644 --- a/packages/hub/tests/e2e/hub-home-board-page.ts +++ b/packages/hub/tests/e2e/hub-home-board-page.ts @@ -9,13 +9,26 @@ import { hubHomeFixture } from './hub-home-fixture'; import { openTasks } from './hub-workspace-fixture'; import { linkedComputersFixture } from './linked-computers-fixture'; import { chooseTheme } from '../../../../test/support/chooseTheme'; +import type { CanaryAsk } from '../../../../scripts/needs-you-canary/canary.types'; export const sizes = { desktop: { width: 1440, height: 900 }, phone: { width: 390, height: 844 } }; export async function boardHome( page: Page, size: keyof typeof sizes, scheme: 'light' | 'dark' = 'dark', - { older = false, questions = 0, extraTasks = 0, legacyAskTitle = '' } = {} + { + older = false, + questions = 0, + extraTasks = 0, + legacyAskTitle = '', + recentCanary + }: { + older?: boolean; + questions?: number; + extraTasks?: number; + legacyAskTitle?: string; + recentCanary?: CanaryAsk; + } = {} ) { await page.setViewportSize(sizes[size]); await chooseTheme(page, scheme); @@ -26,9 +39,23 @@ export async function boardHome( await page.route('**/api/hub-home', (route) => route.fulfill({ json: { granted: false, snapshot: null } }) ); + await page.route('**/api/hub-personal', (route) => route.fulfill({ status: 404 })); const sources = boardSample(); if (legacyAskTitle) sources.items.find(({ id }) => id === 'catalogue')!.title = legacyAskTitle; sources.items.push(...extraQuestions(questions)); + if (recentCanary) { + const item = sources.items.find(({ id }) => id === 'catalogue')!; + Object.assign(item, { + title: recentCanary.title, + question: recentCanary.question, + askedAt: new Date(boardClock).toISOString(), + options: recentCanary.labels.map((label, index) => ({ + label, + effect: 'Synthetic answer', + recommended: index === recentCanary.expected % recentCanary.labels.length + })) + }); + } const template = sources.items[0]; for (let index = 1; index <= extraTasks; index++) { sources.items.push({ @@ -45,7 +72,7 @@ export async function boardHome( await linkedComputersFixture(page, answer, chats); await page.goto('/'); await openTasks(page); - await expect(page.locator('.hb-card[data-needs]')).toHaveCount(1 + questions); + await expect(page.locator('#hb-column-needs .hb-count')).toHaveText(String(1 + questions)); return chats; } diff --git a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts index e4f6dd07344..4c086c3cc3c 100644 --- a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts +++ b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts @@ -2,6 +2,7 @@ import { expect, test, type Page } from '../../../../test/support/browserTest'; import { cardPanel, column, needCards, showColumn } from './hub-home-click-through'; import { boardHome, noSidewaysScroll, sizes } from './hub-home-board-page'; import { captureNeedsYou } from './hub-home-capture'; +import { canaryAsk } from '../../../../scripts/needs-you-canary/canaryAsk'; import { pressOptionScript, rowLabelsScript @@ -36,11 +37,11 @@ for (const size of ['desktop', 'phone'] as const) expect(await page.evaluate(rowLabelsScript('the sample account'))).toBeNull(); expect(await page.evaluate(pressOptionScript(question, 'List'))).toBe(false); await panel.getByRole('button', { name: 'Close viewer' }).click(); - await showColumn(page, 'Needs you'); + await page.goto('/'); + await expect(page.locator('.hs-shell')).toHaveAttribute('data-page', 'home'); const readChoices = () => page.evaluate(rowLabelsScript(question)); - await readChoices(); - await captureNeedsYou(page, `canary-board-${size}`); await expect.poll(readChoices).toContain('List'); + await captureNeedsYou(page, `canary-board-${size}`); expect(await page.evaluate(pressOptionScript('the sample account', 'List'))).toBe(false); expect(await page.evaluate(pressOptionScript(question, 'List'))).toBe(true); await expect @@ -51,11 +52,26 @@ for (const size of ['desktop', 'phone'] as const) for (const size of ['desktop', 'phone'] as const) test(`Needs you is first and never cut short (${size})`, async ({ page }) => { - await boardHome(page, size, 'dark', { questions: 6 }); + const recentCanary = canaryAsk({ + surface: 'web', + release: 'sample', + nonce: 'a0b1c2', + expected: 2, + byHand: false + }); + const chats = await boardHome(page, size, 'dark', { questions: 30, recentCanary }); await showColumn(page, 'Needs you'); - await expect(needCards(page).filter({ visible: true })).toHaveCount(7); + await expect(needCards(page).first()).toBeVisible(); + await expect(needCards(page).filter({ hasText: recentCanary.marker })).toHaveCount(0); await expect(column(page, 'Needs you').getByRole('button', { name: /more$/ })).toHaveCount(0); await expect(page.locator('.hb-column').first()).toHaveAttribute('data-column', 'needs'); + await expect + .poll(() => page.evaluate(rowLabelsScript(recentCanary.marker))) + .toEqual(recentCanary.labels); + expect(await page.evaluate(pressOptionScript(recentCanary.marker, 'Canary B'))).toBe(true); + await expect + .poll(() => chats) + .toMatchObject([{ kind: 'answer', itemId: 'catalogue', option: 2, text: 'Canary B' }]); await noSidewaysScroll(page, sizes[size].width); }); From a84c13584b9806928d0bbe1bb4e41b65d0b4e5de Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 13:47:26 +0000 Subject: [PATCH 4/5] fix: prove the web canary with valid linked asks and dialog choices --- packages/hub/tests/e2e/hub-home-board-page.ts | 16 ++++++++++++++-- .../tests/e2e/hub-home-board-waiting.spec.ts | 17 ++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/hub/tests/e2e/hub-home-board-page.ts b/packages/hub/tests/e2e/hub-home-board-page.ts index 475cbac738a..fca5de0ea85 100644 --- a/packages/hub/tests/e2e/hub-home-board-page.ts +++ b/packages/hub/tests/e2e/hub-home-board-page.ts @@ -1,5 +1,6 @@ import { expect, type Page } from '../../../../test/support/browserTest'; import { buildHomeLiveOverview } from '../../../reports/src/lib/projects-sessions/hub-home/homeLiveOverview'; +import type { PersonalWorkspaceSnapshot } from '../../../reports/src/components/projects-sessions/hub-home/hubPersonalWorkspace.types'; import { buildHomeSnapshot, noProviders @@ -12,6 +13,17 @@ import { chooseTheme } from '../../../../test/support/chooseTheme'; import type { CanaryAsk } from '../../../../scripts/needs-you-canary/canary.types'; export const sizes = { desktop: { width: 1440, height: 900 }, phone: { width: 390, height: 844 } }; +const workScope: PersonalWorkspaceSnapshot = { + mock: true, + scope: 'work', + agents: [], + drafts: [], + replyTasks: [], + reminders: [], + calendarItems: [], + chess: null +}; + export async function boardHome( page: Page, size: keyof typeof sizes, @@ -39,7 +51,7 @@ export async function boardHome( await page.route('**/api/hub-home', (route) => route.fulfill({ json: { granted: false, snapshot: null } }) ); - await page.route('**/api/hub-personal', (route) => route.fulfill({ status: 404 })); + await page.route('**/api/hub-personal', (route) => route.fulfill({ json: workScope })); const sources = boardSample(); if (legacyAskTitle) sources.items.find(({ id }) => id === 'catalogue')!.title = legacyAskTitle; sources.items.push(...extraQuestions(questions)); @@ -52,7 +64,7 @@ export async function boardHome( options: recentCanary.labels.map((label, index) => ({ label, effect: 'Synthetic answer', - recommended: index === recentCanary.expected % recentCanary.labels.length + ...(index === recentCanary.expected % recentCanary.labels.length && { recommended: true }) })) }); } diff --git a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts index 4c086c3cc3c..dd33ade2c15 100644 --- a/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts +++ b/packages/hub/tests/e2e/hub-home-board-waiting.spec.ts @@ -40,8 +40,11 @@ for (const size of ['desktop', 'phone'] as const) await page.goto('/'); await expect(page.locator('.hs-shell')).toHaveAttribute('data-page', 'home'); const readChoices = () => page.evaluate(rowLabelsScript(question)); - await expect.poll(readChoices).toContain('List'); - await captureNeedsYou(page, `canary-board-${size}`); + try { + await expect.poll(readChoices).toEqual(expect.arrayContaining(['Grid', 'List'])); + } finally { + await captureNeedsYou(page, `canary-board-${size}`); + } expect(await page.evaluate(pressOptionScript('the sample account', 'List'))).toBe(false); expect(await page.evaluate(pressOptionScript(question, 'List'))).toBe(true); await expect @@ -65,9 +68,13 @@ for (const size of ['desktop', 'phone'] as const) await expect(needCards(page).filter({ hasText: recentCanary.marker })).toHaveCount(0); await expect(column(page, 'Needs you').getByRole('button', { name: /more$/ })).toHaveCount(0); await expect(page.locator('.hb-column').first()).toHaveAttribute('data-column', 'needs'); - await expect - .poll(() => page.evaluate(rowLabelsScript(recentCanary.marker))) - .toEqual(recentCanary.labels); + try { + await expect + .poll(() => page.evaluate(rowLabelsScript(recentCanary.marker))) + .toEqual(expect.arrayContaining(recentCanary.labels)); + } finally { + await captureNeedsYou(page, `canary-long-board-${size}`); + } expect(await page.evaluate(pressOptionScript(recentCanary.marker, 'Canary B'))).toBe(true); await expect .poll(() => chats) From c9c788babe0880d338583db574d0572fba5489d8 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 13:46:01 +0000 Subject: [PATCH 5/5] fix: find the web canary on the current Tasks board --- scripts/needs-you-canary/hubRowScripts.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/needs-you-canary/hubRowScripts.ts b/scripts/needs-you-canary/hubRowScripts.ts index dcf5a463f85..ae507b69602 100644 --- a/scripts/needs-you-canary/hubRowScripts.ts +++ b/scripts/needs-you-canary/hubRowScripts.ts @@ -7,16 +7,33 @@ const marked = (selector: string, question: string, marker: string) => const detailWith = (marker: string) => marked(details, '.hh-ask-question', marker); const choices = "[...detail.querySelectorAll('.hh-choices button.hh-choice')]"; const labelOf = "choice.querySelector('strong')?.textContent.trim()"; +const tasksTab = '.hs-shell button[data-page="tasks"]:not([aria-current="page"])'; /** Open the matching Needs you card, then read its choices on the next poll. */ export function rowLabelsScript(marker: string): string { + // The nonce is in the task title, which the board search indexes. + const nonce = /^\[canary-([a-f\d]{6})-web\]$/u.exec(marker)?.[1] ?? ''; return `(() => { const detail = ${detailWith(marker)}; if (detail) return ${choices}.map((choice) => ${labelOf}); + if (!document.querySelector('.hb-board')) { + const tasks = [...document.querySelectorAll(${JSON.stringify(tasksTab)})] + .find((button) => button.getClientRects().length > 0); + tasks?.click(); + return null; + } const card = ${marked(cards, '.hb-line', marker)}; - if (!card) return null; - card.querySelector('button[id^="hh-ask-"]')?.click(); - return []; + if (card) { + card.querySelector('button[id^="hh-ask-"]')?.click(); + return []; + } + const search = document.querySelector('.hb-search'); + const nonce = ${JSON.stringify(nonce)}; + if (nonce && search && search.value !== nonce) { + search.value = nonce; + search.dispatchEvent(new Event('input', { bubbles: true })); + } + return null; })()`; }