Multiplayer agent harness for work.
Fold the Inbox migration notice into the sync line (#1774)
Eve Bouffard6996960f3085
diff --git a/plugins/portal/test/playground.test.ts b/plugins/portal/test/playground.test.tsindex 94ead793e..be79675db 100644--- a/plugins/portal/test/playground.test.ts+++ b/plugins/portal/test/playground.test.ts@@ -2,7 +2,7 @@ import test from "node:test";import assert from "node:assert/strict";import { createServer, type IncomingMessage } from "node:http";import type { AddressInfo } from "node:net";-import { spawnSync } from "node:child_process";+import { spawn } from "node:child_process";import { deriveKey, seal, openSession, type SessionClaims } from "../src/session.ts";const claimed = new Set<string>();@@ -151,7 +151,7 @@ test("mintBucketOf keys IPv4 per address and IPv6 per /64", () => {assert.equal(mintBucketOf("fe80::1%en0"), "fe80:0:0:0::/64");});-test("boot refuses playground configurations that leak or brick", () => {+test("boot refuses playground configurations that leak or brick", async () => {const command = "import('./src/index.ts').then(m => m.bootChecks())";const baseEnv: NodeJS.ProcessEnv = {...process.env,@@ -166,8 +166,12 @@ test("boot refuses playground configurations that leak or brick", () => {delete baseEnv.PORTAL_PLAYGROUND_MINTS_PER_IP;delete baseEnv.PORTAL_PLAYGROUND_MINT_WINDOW_S;const boot = (env: NodeJS.ProcessEnv) =>- spawnSync(process.execPath, ["--input-type=module", "-e", command], { cwd: process.cwd(), env, encoding: "utf8" });- assert.equal(boot(baseEnv).status, 0);+ new Promise<{ status: number | null; stderr: string }>((resolve, reject) => {+ const child = spawn(process.execPath, ["--input-type=module", "-e", command], { cwd: process.cwd(), env });+ let stderr = "";+ child.stderr.setEncoding("utf8").on("data", (chunk: string) => (stderr += chunk));+ child.on("error", reject).on("close", (status) => resolve({ status, stderr }));+ });const bad: Array<[NodeJS.ProcessEnv, RegExp]> = [[{ PORTAL_PLAYGROUND_MINTS_PER_IP: "0" }, /between 1 and 64/],[{ PORTAL_PLAYGROUND_MINTS_PER_IP: "65" }, /between 1 and 64/],@@ -181,11 +185,12 @@ test("boot refuses playground configurations that leak or brick", () => {],[{ PORTAL_DEPLOYMENTS_ENABLED: "1" }, /PORTAL_DEPLOYMENTS_ENABLED unset/],];- for (const [extra, pattern] of bad) {- const r = boot({ ...baseEnv, ...extra });- assert.notEqual(r.status, 0, `expected boot failure for ${JSON.stringify(extra)}`);- assert.match(r.stderr, pattern);- }+ const [ok, ...refused] = await Promise.all([baseEnv, ...bad.map(([extra]) => ({ ...baseEnv, ...extra }))].map(boot));+ assert.equal(ok!.status, 0);+ bad.forEach(([extra, pattern], i) => {+ assert.notEqual(refused[i]!.status, 0, `expected boot failure for ${JSON.stringify(extra)}`);+ assert.match(refused[i]!.stderr, pattern);+ });});test("mints beyond the per-IP budget are refused, and refusal sets no cookie", async () => {diff --git a/plugins/web-ui/src/inbox.ts b/plugins/web-ui/src/inbox.tsindex f377d02c7..7c9e3be2f 100644--- a/plugins/web-ui/src/inbox.ts+++ b/plugins/web-ui/src/inbox.ts@@ -1512,6 +1512,9 @@ function itemRowTpl(surface: InboxSurface, item: InboxItem): TemplateResult {`;}+const MIGRATION_STATUS = "Moving your Inbox…";+const MIGRATION_HINT = "Available once your existing Inbox finishes moving";+function syncStatusLabel(cron: InboxSyncCron): string {if (!cron.enabled) return "Sync paused";return cron.lastFiredAt ? `Synced ${relTime(cron.lastFiredAt)}` : "First sync pending";@@ -1521,6 +1524,7 @@ function syncActionTpl(opts: {label: string;busyLabel: string;busy: boolean;+ disabled?: boolean;tooltip: string;action: () => void;}): TemplateResult {@@ -1528,7 +1532,7 @@ function syncActionTpl(opts: {class="btn inbox-sync-action"type="button"${tip(opts.tooltip)}- ?disabled=${opts.busy}+ ?disabled=${opts.busy || opts.disabled}@click=${opts.action}>${icon(RefreshCw, 13)}<span>${opts.busy ? opts.busyLabel : opts.label}</span>@@ -1554,18 +1558,20 @@ function syncLineTpl(surface: InboxSurface): TemplateResult | typeof nothing {}const loops = syncLoops(surface.viewId);const crons = loops.flatMap((loop) => (loop.syncCron ? [loop.syncCron] : []));- if (!crons.length) return nothing;+ const moving = inboxState.migrationPending;+ if (!crons.length && !moving) return nothing;+ const status =+ crons.length === 1 ? syncStatusLabel(crons[0]!) : `${crons.filter((cron) => cron.enabled).length} syncs on`;return html`<span class="inbox-sync-line">${syncActionTpl({label: "Sync",busyLabel: "Syncing…",busy: inboxState.syncBusy,- tooltip: "Sync now",+ disabled: moving,+ tooltip: moving ? MIGRATION_HINT : "Sync now",action: () => void syncNow(surface.viewId),})}- <span class="inbox-sync-status"- >${crons.length === 1 ? syncStatusLabel(crons[0]!) : `${crons.filter((cron) => cron.enabled).length} syncs on`}</span- >+ <span class="inbox-sync-status" role=${moving ? "status" : nothing}>${moving ? MIGRATION_STATUS : status}</span></span>`;}@@ -1586,6 +1592,7 @@ function surfaceTpl(surface: InboxSurface): TemplateResult {emptyMessage = "Nothing is waiting on you. Choose From people or All emails to see more emails.";if (surface.viewId === "sent") emptyMessage = "No sent messages yet. Sent Email and Slack replies will appear here.";const handledItems = itemsFor(surface.viewId, "handled");+ const hasMore = !!feedWindows.get(surface.viewId)?.nextCursor;const setupLoops = inboxState.selected.filter((loop) =>loop.source && !loop.cronId && !loop.ingestionActive && (surface.viewId === loop.id || surface.viewId === "all"),@@ -1697,38 +1704,53 @@ function surfaceTpl(surface: InboxSurface): TemplateResult {${icon(surface.showHandled ? ChevronDown : ChevronRight, 13)}<span>Handled (${handledItems.length})</span></button>- ${surface.showHandled ? html`<div class="inbox-list handled">${handledItems.map((i) => itemRowTpl(surface, i))}</div>` : nothing}${surface.showHandled && feedWindows.get(`handled:${surface.viewId}`)?.nextCursor ? html`<button class="btn" ?disabled=${inboxState.loading} @click=${() => void refreshInbox({ more: true, viewId: `handled:${surface.viewId}` })}>Load more handled</button>` : nothing}+ ${surface.showHandled ? html`<div class="inbox-list handled">${handledItems.map((i) => itemRowTpl(surface, i))}</div>` : nothing}${surface.showHandled && feedWindows.get(`handled:${surface.viewId}`)?.nextCursor ? html`<button class="inbox-load-more" type="button" ?disabled=${inboxState.loading} @click=${() => void refreshInbox({ more: true, viewId: `handled:${surface.viewId}` })}>Load more handled</button>` : nothing}`: nothing}`;return html`<div class="inbox-surface ${compact ? "compact" : ""}" data-density=${density}>- ${inboxState.migrationPending ? html`<div class="inbox-notice" role="status">Moving your existing Inbox. Sync setup will be available once active work finishes and records are verified.</div>` : nothing}<div class="inbox-toolbar">${chips} ${surface.pane ? html`<span class="inbox-toolbar-spacer"></span>${syncLineTpl(surface)}` : nothing}</div>${- showEmailFilter+ showEmailFilter || hasMore? html`<div class="inbox-filter-bar">- <label class="inbox-filter">- <span>Emails</span>- ${fieldSelect({- className: "inbox-filter-control",- ariaLabel: "Email filter",- ariaDescription: INBOX_FILTERS.find((filter) => filter.id === inboxState.filter)?.description,- value: inboxState.filter,- disabled: inboxState.filterBusy || inboxState.loading,- onChange: (value) => void selectInboxFilter(value as InboxFilter),- options: INBOX_FILTERS.map(- (filter) =>- html`<option value=${filter.id} ?selected=${filter.id === inboxState.filter}>- ${filter.label}- </option>`,- ),- })}- </label>+ ${+ showEmailFilter+ ? html`<label class="inbox-filter">+ <span>Emails</span>+ ${fieldSelect({+ className: "inbox-filter-control",+ ariaLabel: "Email filter",+ ariaDescription: INBOX_FILTERS.find((filter) => filter.id === inboxState.filter)?.description,+ value: inboxState.filter,+ disabled: inboxState.filterBusy || inboxState.loading,+ onChange: (value) => void selectInboxFilter(value as InboxFilter),+ options: INBOX_FILTERS.map(+ (filter) =>+ html`<option value=${filter.id} ?selected=${filter.id === inboxState.filter}>+ ${filter.label}+ </option>`,+ ),+ })}+ </label>`+ : nothing+ }+ ${+ hasMore+ ? html`<button+ class="inbox-load-more"+ type="button"+ ?disabled=${inboxState.loading}+ @click=${() => void refreshInbox({ more: true, viewId: surface.viewId })}+ >+ Load more+ </button>`+ : nothing+ }</div>`: nothing@@ -1742,11 +1764,14 @@ function surfaceTpl(surface: InboxSurface): TemplateResult {<span class="inbox-setup-icon" aria-hidden="true">${loopIcon(loop, 17)}</span><div class="inbox-setup-copy"><span class="inbox-setup-title">${loop.name}</span- ><span class="inbox-setup-description">Sync not set up</span>+ ><span class="inbox-setup-description"+ >${inboxState.migrationPending ? MIGRATION_STATUS : "Sync not set up"}</span+ ></div><buttonclass="inbox-setup-action"aria-label=${`Set up ${loop.name}`}+ ${inboxState.migrationPending ? tip(MIGRATION_HINT) : nothing}?disabled=${inboxState.syncBusy || inboxState.migrationPending}@click=${() => void setUpSync(loop.id)}>@@ -1808,7 +1833,6 @@ function surfaceTpl(surface: InboxSurface): TemplateResult {</section>`: nothing}- ${feedWindows.get(surface.viewId)?.nextCursor ? html`<button class="btn" ?disabled=${inboxState.loading} @click=${() => void refreshInbox({ more: true, viewId: surface.viewId })}>Load more</button>` : nothing}${inboxState.notice ? html`<div class="inbox-notice" role="status">${inboxState.notice}</div>` : nothing}<div class="inbox-scroll">${diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.cssindex 69facc90f..572fb4c1e 100644--- a/plugins/web-ui/src/shell.css+++ b/plugins/web-ui/src/shell.css@@ -9626,8 +9626,31 @@ h3.ambient-field-label {border-bottom: 1px solid var(--border);}.inbox-filter-bar {+ display: flex;+ align-items: center;+ gap: 8px;padding: 0 10px 18px;}+.inbox-filter-bar:not(:has(.inbox-filter)) {+ padding-bottom: 0;+}+.inbox-load-more {+ margin-left: auto;+ padding: 4px 2px;+ border: 0;+ background: none;+ color: var(--muted-foreground);+ font: inherit;+ font-size: var(--font-12-5);+ cursor: pointer;+}+.inbox-load-more:hover:not(:disabled) {+ color: var(--foreground);+}+.inbox-load-more:disabled {+ opacity: 0.6;+ cursor: wait;+}.inbox-page .inbox-filter-bar {padding-inline: 0;}@@ -10648,7 +10671,7 @@ h3.ambient-field-label {.inbox-surface.compact .inbox-item-detail {padding: 2px 10px 12px;}-.inbox-surface.compact .inbox-sync-line > .inbox-sync-status {+.inbox-surface.compact .inbox-sync-line > .inbox-sync-status:not([role="status"]) {display: none;}.inbox-surface[data-density="min"] .inbox-item-sub,diff --git a/plugins/web-ui/test/inbox-source.test.ts b/plugins/web-ui/test/inbox-source.test.tsindex 864d60821..2854c8ed0 100644--- a/plugins/web-ui/test/inbox-source.test.ts+++ b/plugins/web-ui/test/inbox-source.test.ts@@ -121,6 +121,20 @@ test("the inbox reads a paginated combined feed and retains original item refereassert.match(inbox, /loadDeepLink/);});+test("load more is a text button at the end of the filter row, not a full-width bar above the list", () => {+ assert.match(inbox, /const hasMore = !!feedWindows\.get\(surface\.viewId\)\?\.nextCursor;/);+ assert.match(inbox, /showEmailFilter \|\| hasMore\s*\? html`\s*<div class="inbox-filter-bar">/);+ assert.match(+ inbox,+ /class="inbox-load-more"[\s\S]*?refreshInbox\(\{ more: true, viewId: surface\.viewId \}\)[\s\S]*?Load more/,+ );+ assert.doesNotMatch(inbox, /<button class="btn"[^\n]*>Load more/);+ assert.match(inbox, /<button class="inbox-load-more" type="button"[^\n]*handled:[^\n]*>Load more handled<\/button>/);+ assert.match(css, /\.inbox-filter-bar \{\s*display: flex;/);+ assert.match(css, /\.inbox-load-more \{\s*margin-left: auto;/);+ assert.match(css, /\.inbox-filter-bar:not\(:has\(\.inbox-filter\)\) \{\s*padding-bottom: 0;/);+});+test("localhost can overlay private inbox seed data without checking it into source", () => {assert.match(inbox, /fetch\("\/inbox-seed\.local\.json", \{ cache: "no-store" \}\)/);assert.match(diff --git a/plugins/web-ui/test/inbox-sync-actions.test.ts b/plugins/web-ui/test/inbox-sync-actions.test.tsindex b369b767b..497556f5e 100644--- a/plugins/web-ui/test/inbox-sync-actions.test.ts+++ b/plugins/web-ui/test/inbox-sync-actions.test.ts@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";import test from "node:test";const source = readFileSync(new URL("../src/inbox.ts", import.meta.url), "utf8");+const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");test("inbox sync states use the same labeled action button", () => {assert.match(source, /function syncActionTpl/);@@ -14,3 +15,25 @@ test("inbox sync states use the same labeled action button", () => {assert.match(source, /busyLabel: "Syncing…"/);assert.match(source, /"Setting up…" : "Set up"/);});++test("a pending inbox migration lives in the sync line instead of a banner", () => {+ assert.doesNotMatch(source, /Moving your existing Inbox/);+ assert.doesNotMatch(source, /migrationPending \? html`<div class="inbox-notice"/);+ assert.match(+ source,+ /const moving = inboxState\.migrationPending;\s*if \(!crons\.length && !moving\) return nothing;/,+ );+ assert.match(source, /disabled: moving,/);+ assert.match(source, /tooltip: moving \? MIGRATION_HINT : "Sync now"/);+ assert.match(+ source,+ /<span class="inbox-sync-status" role=\$\{moving \? "status" : nothing\}>\$\{moving \? MIGRATION_STATUS : status\}<\/span>/,+ );+ assert.match(source, /inboxState\.migrationPending \? MIGRATION_STATUS : "Sync not set up"/);+ assert.match(source, /\$\{inboxState\.migrationPending \? tip\(MIGRATION_HINT\) : nothing\}/);+ assert.match(source, /\?disabled=\$\{inboxState\.syncBusy \|\| inboxState\.migrationPending\}/);+ assert.match(+ css,+ /\.inbox-surface\.compact \.inbox-sync-line > \.inbox-sync-status:not\(\[role="status"\]\) \{\s*display: none;/,+ );+});