@firstpick/pi-package-webui 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/bin/pi-webui.mjs +375 -30
- package/index.ts +8 -1
- package/lib/git-workflow-preferences.mjs +3 -0
- package/lib/session-summary-core.mjs +4 -3
- package/lib/trust-boundaries.mjs +13 -0
- package/lib/workspace-session-summaries.mjs +400 -0
- package/package.json +2 -2
- package/public/app.js +1197 -267
- package/public/index.html +76 -3
- package/public/service-worker.js +3 -1
- package/public/stream-output-controller.mjs +327 -0
- package/public/styles.css +249 -70
- package/public/theme-contract.mjs +244 -0
- package/session-summary.ts +164 -4
- package/tests/aur-review-widget-static.test.mjs +2 -1
- package/tests/browser/interaction-continuity.spec.mjs +2 -2
- package/tests/browser/session-summary.spec.mjs +131 -3
- package/tests/browser/stream-output-isolation.spec.mjs +510 -0
- package/tests/codex-fast-mode-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +1 -1
- package/tests/fast-mode-client-static.test.mjs +2 -1
- package/tests/fixtures/fake-pi.mjs +203 -2
- package/tests/git-workflow-preferences.test.mjs +7 -1
- package/tests/guided-git-aur-review.test.mjs +4 -3
- package/tests/http-endpoints-harness.test.mjs +207 -6
- package/tests/mobile-continuity-tablet-static.test.mjs +1 -1
- package/tests/mobile-foundation-static.test.mjs +2 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +62 -29
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -3
- package/tests/persistent-ui-layout-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +1 -1
- package/tests/remote-auth-settings-harness.test.mjs +9 -0
- package/tests/session-summary-core.test.mjs +183 -1
- package/tests/side-panel-section-reorder-static.test.mjs +1 -1
- package/tests/stream-lifecycle-core.test.mjs +134 -0
- package/tests/stream-output-controller.test.mjs +252 -0
- package/tests/stream-output-isolation-static.test.mjs +89 -0
- package/tests/streaming-ui-coupling.test.mjs +50 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +104 -0
- package/tests/theme-customizer-static.test.mjs +82 -0
- package/tests/theme-scheme-mode.test.mjs +15 -0
- package/tests/workspace-session-summaries.test.mjs +288 -0
package/session-summary.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
3
4
|
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
5
|
import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
5
6
|
import { Markdown } from "@earendil-works/pi-tui";
|
|
7
|
+
import { Type } from "typebox";
|
|
6
8
|
import {
|
|
7
9
|
SESSION_SUMMARY_DISPLAY_TYPE,
|
|
8
10
|
SESSION_SUMMARY_MAX_OUTPUT_TOKENS,
|
|
@@ -29,6 +31,13 @@ import {
|
|
|
29
31
|
supportedSessionSummaryThinkingLevels,
|
|
30
32
|
writeSessionSummaryPreferences,
|
|
31
33
|
} from "./lib/session-summary-preferences.mjs";
|
|
34
|
+
import {
|
|
35
|
+
createLiveSummaryPayload,
|
|
36
|
+
discoverPersistedWorkspaceSummaries,
|
|
37
|
+
formatWorkspaceSummariesForCommand,
|
|
38
|
+
formatWorkspaceSummariesForTool,
|
|
39
|
+
mergeWorkspaceSessionSummaries,
|
|
40
|
+
} from "./lib/workspace-session-summaries.mjs";
|
|
32
41
|
|
|
33
42
|
type SummaryContext = ExtensionContext | ExtensionCommandContext;
|
|
34
43
|
type CompleteFunction = typeof completeSimple;
|
|
@@ -170,6 +179,133 @@ async function runSetup(pi: ExtensionAPI, ctx: ExtensionCommandContext): Promise
|
|
|
170
179
|
export function createSessionSummaryExtension({ completeFn = completeSimple }: { completeFn?: CompleteFunction } = {}) {
|
|
171
180
|
return function registerSessionSummary(pi: ExtensionAPI): void {
|
|
172
181
|
let selfGeneratedName: { sessionId: string; name: string } | undefined;
|
|
182
|
+
let activeContext: SummaryContext | undefined;
|
|
183
|
+
let liveAvailable = false;
|
|
184
|
+
let activeChannel: any;
|
|
185
|
+
let channelRegistered = false;
|
|
186
|
+
const livePeers = new Map<string, { senderId: string; payload: unknown; receivedAt?: string }>();
|
|
187
|
+
|
|
188
|
+
const channelIsLive = (): boolean => {
|
|
189
|
+
try {
|
|
190
|
+
const snapshot = activeChannel?.snapshot?.();
|
|
191
|
+
return snapshot?.connected === true && snapshot?.supported === true;
|
|
192
|
+
} catch {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const publishLiveSummary = (ctx: SummaryContext | undefined = activeContext): void => {
|
|
198
|
+
if (!ctx || !activeChannel || !channelIsLive()) return;
|
|
199
|
+
try {
|
|
200
|
+
const state = latestSummaryState(ctx.sessionManager.getBranch());
|
|
201
|
+
if (!state) return;
|
|
202
|
+
const payload = createLiveSummaryPayload({ cwd: ctx.cwd, state, sessionName: pi.getSessionName() });
|
|
203
|
+
if (payload) activeChannel.publish(payload, { audience: "capable" });
|
|
204
|
+
} catch {
|
|
205
|
+
// The optional live channel must never break local summary behavior.
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const setupLiveChannel = (channel: any): void => {
|
|
210
|
+
if (!channel || typeof channel.snapshot !== "function" || typeof channel.publish !== "function" || typeof channel.listSessions !== "function") return;
|
|
211
|
+
activeChannel = channel;
|
|
212
|
+
liveAvailable = channelIsLive();
|
|
213
|
+
if (liveAvailable) publishLiveSummary();
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const handleLiveChannelEvent = (event: any): void => {
|
|
217
|
+
if (!event || typeof event.type !== "string") return;
|
|
218
|
+
if (event.type === "connection") {
|
|
219
|
+
liveAvailable = event.connected === true && event.supported === true;
|
|
220
|
+
if (!liveAvailable) {
|
|
221
|
+
livePeers.clear();
|
|
222
|
+
} else {
|
|
223
|
+
publishLiveSummary();
|
|
224
|
+
}
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (event.type === "message" && typeof event.fromSessionId === "string") {
|
|
228
|
+
livePeers.set(event.fromSessionId, {
|
|
229
|
+
senderId: event.fromSessionId,
|
|
230
|
+
payload: event.payload,
|
|
231
|
+
receivedAt: new Date().toISOString(),
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (event.type === "session_left" && typeof event.sessionId === "string") {
|
|
236
|
+
livePeers.delete(event.sessionId);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (event.type === "session_joined") {
|
|
240
|
+
if (typeof event.session?.id === "string") livePeers.delete(event.session.id);
|
|
241
|
+
publishLiveSummary();
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const registerLiveChannel = (): void => {
|
|
246
|
+
if (channelRegistered || !pi.events || typeof pi.events.emit !== "function") return;
|
|
247
|
+
channelRegistered = true;
|
|
248
|
+
try {
|
|
249
|
+
pi.events.emit("intercom:extension-register", {
|
|
250
|
+
namespace: "firstpick/session-summary/v1",
|
|
251
|
+
ownerEligible: false,
|
|
252
|
+
onReady: setupLiveChannel,
|
|
253
|
+
onEvent: handleLiveChannelEvent,
|
|
254
|
+
});
|
|
255
|
+
} catch {
|
|
256
|
+
// pi-intercom is optional; persisted discovery remains available.
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const getWorkspaceSnapshot = async (ctx: SummaryContext) => {
|
|
261
|
+
const cwd = ctx.cwd;
|
|
262
|
+
const currentSessionId = ctx.sessionManager.getSessionId();
|
|
263
|
+
const currentState = latestSummaryState(ctx.sessionManager.getBranch());
|
|
264
|
+
const currentSessionName = pi.getSessionName();
|
|
265
|
+
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
266
|
+
const configuredSessionDir = (ctx.sessionManager as any).getSessionDir?.();
|
|
267
|
+
const sessionDir = typeof configuredSessionDir === "string" && configuredSessionDir
|
|
268
|
+
? configuredSessionDir
|
|
269
|
+
: sessionFile ? path.dirname(sessionFile) : undefined;
|
|
270
|
+
const persisted = await discoverPersistedWorkspaceSummaries({ cwd, sessionDir, currentSessionId });
|
|
271
|
+
|
|
272
|
+
let connectedSessions: any[] = [];
|
|
273
|
+
liveAvailable = channelIsLive();
|
|
274
|
+
if (liveAvailable) {
|
|
275
|
+
try {
|
|
276
|
+
connectedSessions = await activeChannel.listSessions();
|
|
277
|
+
} catch {
|
|
278
|
+
liveAvailable = false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return mergeWorkspaceSessionSummaries({
|
|
283
|
+
cwd,
|
|
284
|
+
currentSessionId,
|
|
285
|
+
currentState,
|
|
286
|
+
currentSessionName,
|
|
287
|
+
livePeers: [...livePeers.values()],
|
|
288
|
+
connectedSessions,
|
|
289
|
+
persisted,
|
|
290
|
+
liveAvailable,
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
pi.registerTool({
|
|
295
|
+
name: "workspace_session_summaries",
|
|
296
|
+
label: "Workspace Session Summaries",
|
|
297
|
+
description: "Show bounded generated summaries from current, connected, and persisted Pi sessions in the same canonical working directory so overlap can be identified before writes.",
|
|
298
|
+
promptSnippet: "Inspect same-CWD session summaries before potentially overlapping repository work",
|
|
299
|
+
promptGuidelines: [
|
|
300
|
+
"Use workspace_session_summaries when another Pi session in the same working directory may overlap the current work.",
|
|
301
|
+
"After workspace_session_summaries, compare goals, files or symbols, decisions, and next steps; when overlap is material or ownership is unclear, coordinate through intercom before writing.",
|
|
302
|
+
],
|
|
303
|
+
parameters: Type.Object({}, { additionalProperties: false }),
|
|
304
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
|
305
|
+
const snapshot = await getWorkspaceSnapshot(ctx);
|
|
306
|
+
return { content: [{ type: "text", text: formatWorkspaceSummariesForTool(snapshot) }], details: snapshot.counts };
|
|
307
|
+
},
|
|
308
|
+
});
|
|
173
309
|
|
|
174
310
|
const publishCurrentState = async (ctx: SummaryContext): Promise<void> => {
|
|
175
311
|
const state = latestSummaryState(ctx.sessionManager.getBranch());
|
|
@@ -239,7 +375,7 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
239
375
|
return { stale: true };
|
|
240
376
|
}
|
|
241
377
|
|
|
242
|
-
const currentName = pi.getSessionName();
|
|
378
|
+
const currentName = typeof (pi as any).getSessionName === "function" ? (pi as any).getSessionName() : undefined;
|
|
243
379
|
const applyTitle = shouldApplySummaryTitle({
|
|
244
380
|
candidate: output.title,
|
|
245
381
|
currentSessionName: currentName,
|
|
@@ -285,6 +421,7 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
285
421
|
sendRpc(pi, ctx, "title", { title: output.title });
|
|
286
422
|
}
|
|
287
423
|
sendRpc(pi, ctx, "success", { title: state.result.title, summaryMarkdown: state.result.summaryMarkdown });
|
|
424
|
+
publishLiveSummary(ctx);
|
|
288
425
|
if (!ctx.sessionManager.getSessionFile() && manual) ctx.ui.notify("Summary created in memory; this session has no durable session file.", "warning");
|
|
289
426
|
return { state, appliedTitle: applyTitle };
|
|
290
427
|
} catch (error) {
|
|
@@ -319,6 +456,7 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
319
456
|
});
|
|
320
457
|
|
|
321
458
|
pi.on("session_info_changed", (event, ctx) => {
|
|
459
|
+
activeContext = ctx;
|
|
322
460
|
if (selfGeneratedName?.sessionId === ctx.sessionManager.getSessionId() && selfGeneratedName.name === event.name) {
|
|
323
461
|
selfGeneratedName = undefined;
|
|
324
462
|
return;
|
|
@@ -328,20 +466,26 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
328
466
|
version: 1,
|
|
329
467
|
explicit: event.name !== undefined,
|
|
330
468
|
});
|
|
469
|
+
publishLiveSummary(ctx);
|
|
331
470
|
});
|
|
332
471
|
|
|
333
472
|
pi.on("session_start", async (_event, ctx) => {
|
|
334
473
|
selfGeneratedName = undefined;
|
|
474
|
+
activeContext = ctx;
|
|
475
|
+
registerLiveChannel();
|
|
335
476
|
try {
|
|
336
477
|
await publishCurrentState(ctx);
|
|
478
|
+
publishLiveSummary(ctx);
|
|
337
479
|
} catch (error) {
|
|
338
480
|
sendRpc(pi, ctx, "failure", { message: errorMessage(error) });
|
|
339
481
|
}
|
|
340
482
|
});
|
|
341
483
|
|
|
342
484
|
pi.on("session_tree", async (_event, ctx) => {
|
|
485
|
+
activeContext = ctx;
|
|
343
486
|
try {
|
|
344
487
|
await publishCurrentState(ctx);
|
|
488
|
+
publishLiveSummary(ctx);
|
|
345
489
|
} catch (error) {
|
|
346
490
|
sendRpc(pi, ctx, "failure", { message: errorMessage(error) });
|
|
347
491
|
}
|
|
@@ -349,6 +493,10 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
349
493
|
|
|
350
494
|
pi.on("session_shutdown", () => {
|
|
351
495
|
selfGeneratedName = undefined;
|
|
496
|
+
activeContext = undefined;
|
|
497
|
+
activeChannel = undefined;
|
|
498
|
+
liveAvailable = false;
|
|
499
|
+
livePeers.clear();
|
|
352
500
|
scheduler.abort();
|
|
353
501
|
});
|
|
354
502
|
|
|
@@ -364,8 +512,20 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
364
512
|
};
|
|
365
513
|
|
|
366
514
|
pi.registerCommand("summary", {
|
|
367
|
-
description: "Show the latest session summary or generate one; use /summary refresh to force an update",
|
|
515
|
+
description: "Show the latest session summary or generate one; use /summary refresh to force an update, or /summary workspace to view all workspace session summaries",
|
|
368
516
|
handler: async (args, ctx) => {
|
|
517
|
+
const trimmed = args.trim().toLowerCase();
|
|
518
|
+
if (trimmed === "workspace") {
|
|
519
|
+
const snapshot = await getWorkspaceSnapshot(ctx);
|
|
520
|
+
const text = formatWorkspaceSummariesForCommand(snapshot);
|
|
521
|
+
pi.appendEntry(SESSION_SUMMARY_DISPLAY_TYPE, {
|
|
522
|
+
version: 1,
|
|
523
|
+
title: "Workspace session summaries",
|
|
524
|
+
summaryMarkdown: text,
|
|
525
|
+
});
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
369
529
|
const preferences = await readSessionSummaryPreferences().catch((error) => {
|
|
370
530
|
ctx.ui.notify(`Session summary settings failed: ${errorMessage(error)}`, "error");
|
|
371
531
|
return undefined;
|
|
@@ -376,9 +536,9 @@ export function createSessionSummaryExtension({ completeFn = completeSimple }: {
|
|
|
376
536
|
await generateManual(ctx);
|
|
377
537
|
} else {
|
|
378
538
|
const state = latestSummaryState(ctx.sessionManager.getBranch());
|
|
379
|
-
const refresh =
|
|
539
|
+
const refresh = trimmed === "refresh";
|
|
380
540
|
if (args.trim() && !refresh) {
|
|
381
|
-
ctx.ui.notify("Usage: /summary [refresh]", "warning");
|
|
541
|
+
ctx.ui.notify("Usage: /summary [refresh | workspace]", "warning");
|
|
382
542
|
return;
|
|
383
543
|
}
|
|
384
544
|
if (!state || refresh) await generateManual(ctx);
|
|
@@ -21,6 +21,7 @@ assert.match(payloadParser, /decision\.reviewedFingerprint !== payload\.fingerpr
|
|
|
21
21
|
assert.match(payloadParser, /stagedPayload \? decision\.reviewedStagedContentHash !== payload\.stagedContentHash/, "payload parsing should bind staged terminal decisions to the staged-content hash");
|
|
22
22
|
assert.match(payloadParser, /payload\.changedFiles\.length >= payload\.changedFileTotal/, "payload parsing should reject equality at the truncated-file boundary");
|
|
23
23
|
assert.match(app, /function renderAurReviewWidget\(\)[\s\S]*Review changes[\s\S]*Refresh[\s\S]*Approve[\s\S]*Decline[\s\S]*Close[\s\S]*openAurReviewReportInViewer\(reportPath, payload\.repoRoot\)/, "renderer should open reports against the payload's repo root rather than the tab cwd");
|
|
24
|
+
assert.match(app, /payload\.origin === "guided-git" && payload\.scope === "staged" && payload\.decision\.state === "approved"[\s\S]*return null/, "an approved Guided Git staged review should close its manual review card");
|
|
24
25
|
assert.match(app, /async function openAurReviewReportInViewer\(path = "", repoRoot = ""\)[\s\S]*\/api\/aur-review\/report-content[\s\S]*readOnly: true/s, "report viewing must use the narrow read-only canonical-root endpoint");
|
|
25
26
|
assert.match(app, /viewer\.readOnly === true \|\| !viewer\.dirty[\s\S]*viewer\.readOnly === true \|\| !viewerPath/s, "repo-root report views must not enable generic save or default-editor actions");
|
|
26
27
|
assert.match(app, /function aurReviewActionButton\(label, action, className = ""\)[\s\S]*action === "review"[\s\S]*openGitChangesDialog\(\)[\s\S]*`\/aur-review \$\{action\}`/, "Review changes should reuse the current Git diff dialog and other controls should call canonical extension commands");
|
|
@@ -32,7 +33,7 @@ assert.match(css, /\.aur-review-widget \{[\s\S]*\.aur-review-actions[\s\S]*\.aur
|
|
|
32
33
|
assert.equal(JSON.parse(pkg).optionalDependencies?.["@firstpick/pi-extension-aur-review"], undefined, "WebUI must not reference the unpublished review extension from clean npm installs");
|
|
33
34
|
assert.equal(JSON.parse(pkg).pi?.extensions?.some((entry) => String(entry).includes("pi-extension-aur-review")), false, "WebUI must not bundle an unpublished nested review extension path");
|
|
34
35
|
assert.match(optionalFeatureCatalog, /\["aurReview", "@firstpick\/pi-extension-aur-review", "\^0\.1\.1"\]/, "optional-feature catalog should retain the future/local review companion mapping without bundling it");
|
|
35
|
-
assert.match(server, /"
|
|
36
|
+
assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "server must serve typed browser modules from the public asset boundary");
|
|
36
37
|
assert.match(server, /STAGED_CONTENT_HASH_DOMAIN = "firstpick\/aur-review\/staged-content\/v1\\0"[\s\S]*git diff --cached[\s\S]*\/api\/git-workflow\/staged-content/, "server must expose the bounded read-only staged-content hash helper");
|
|
37
38
|
assert.match(server, /async function getAurReviewReportContentData\(tab, \{ path: requestedPath = "", repoRoot = "" \} = \{\}\)[\s\S]*repoRoot !== root[\s\S]*lstat\(targetPath\)[\s\S]*isSymbolicLink\(\)[\s\S]*readBoundedAurReviewReport[\s\S]*\/api\/aur-review\/report-content/s, "server must bind report reads to the canonical Git root and reject symlinked paths through a dedicated read-only route");
|
|
38
39
|
assert.match(server, /entry\.name\.startsWith\("pi-"\)[\s\S]*packageNameForResourcePath\(path\.join\(candidate, "package\.json"\)\)/, "workspace optional-package discovery must recognize the pi-extension-aur-review sibling by manifest name");
|
|
@@ -713,9 +713,9 @@ test("individually expanded tool details stay open through transcript rerenders"
|
|
|
713
713
|
await triggerTranscriptContinuity(page, "tool");
|
|
714
714
|
const details = page.locator(".message.toolExecution .tool-raw-details").last();
|
|
715
715
|
await expect(details).toBeAttached();
|
|
716
|
-
await expect
|
|
716
|
+
await expect(details).toContainText("unselected revision one");
|
|
717
717
|
const summary = details.locator("summary");
|
|
718
|
-
await
|
|
718
|
+
await details.evaluate((node) => { node.open = true; });
|
|
719
719
|
await expect.poll(() => details.evaluate((node) => node.open)).toBe(true);
|
|
720
720
|
await waitForFixtureSettlement(page);
|
|
721
721
|
const rawOutput = details.locator(".tool-raw-code");
|
|
@@ -106,6 +106,10 @@ function generatedSummaryResponse() {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async function installSummaryRoutes(page, requests, { configured = false, summary = null, generate = generatedSummaryResponse } = {}) {
|
|
109
|
+
const requestTabId = (route) => new URL(route.request().url()).searchParams.get("tab");
|
|
110
|
+
requests.getTabs = [];
|
|
111
|
+
requests.putTabs = [];
|
|
112
|
+
requests.generateTabs = [];
|
|
109
113
|
await page.route("**/api/commands?*", async (route) => {
|
|
110
114
|
await route.fulfill({
|
|
111
115
|
status: 200,
|
|
@@ -118,16 +122,21 @@ async function installSummaryRoutes(page, requests, { configured = false, summar
|
|
|
118
122
|
});
|
|
119
123
|
await page.route("**/api/session-summary/preferences?*", async (route) => {
|
|
120
124
|
const method = route.request().method();
|
|
125
|
+
const tabId = requestTabId(route);
|
|
121
126
|
if (method === "GET") {
|
|
122
127
|
requests.get += 1;
|
|
123
|
-
|
|
128
|
+
requests.getTabs.push(tabId);
|
|
129
|
+
const tabSummary = typeof summary === "function" ? summary(tabId) : summary;
|
|
130
|
+
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: preferencesData({ configured, summary: tabSummary }) }) });
|
|
124
131
|
return;
|
|
125
132
|
}
|
|
133
|
+
requests.putTabs.push(tabId);
|
|
126
134
|
requests.put.push(JSON.parse(route.request().postData() || "{}"));
|
|
127
135
|
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: preferencesData({ configured: true }) }) });
|
|
128
136
|
});
|
|
129
137
|
await page.route("**/api/session-summary/generate?*", async (route) => {
|
|
130
138
|
const request = JSON.parse(route.request().postData() || "{}");
|
|
139
|
+
requests.generateTabs.push(requestTabId(route));
|
|
131
140
|
requests.generate.push(request);
|
|
132
141
|
const response = await generate(request, requests.generate.length);
|
|
133
142
|
await route.fulfill({
|
|
@@ -143,7 +152,7 @@ test("first click opens confirmed setup, cancel has no side effect, and save ope
|
|
|
143
152
|
await installSummaryRoutes(page, requests);
|
|
144
153
|
await page.goto(baseURL);
|
|
145
154
|
|
|
146
|
-
const summaryButton = page.locator("
|
|
155
|
+
const summaryButton = page.locator(".terminal-tab.active[data-tab-id] > .terminal-tab-actions > .terminal-tab-summary-button");
|
|
147
156
|
await expect(summaryButton).toBeVisible();
|
|
148
157
|
await summaryButton.evaluate((button) => button.click());
|
|
149
158
|
await expect(page.locator("#nativeCommandDialog")).toBeVisible();
|
|
@@ -231,7 +240,7 @@ test("typed summary commands stay native, preserve failures, reset sessions, res
|
|
|
231
240
|
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: {} }) });
|
|
232
241
|
});
|
|
233
242
|
await page.goto(baseURL);
|
|
234
|
-
await expect(page.locator("
|
|
243
|
+
await expect(page.locator(".terminal-tab.active[data-tab-id] > .terminal-tab-actions > .terminal-tab-summary-button")).toBeVisible();
|
|
235
244
|
|
|
236
245
|
const prompt = page.locator("#promptInput");
|
|
237
246
|
await prompt.fill("/summary");
|
|
@@ -269,3 +278,122 @@ test("typed summary commands stay native, preserve failures, reset sessions, res
|
|
|
269
278
|
await expect(page.locator("#tabBar [role=\"tab\"]")).toHaveCount(2);
|
|
270
279
|
await expect(page.locator("#sessionSummaryOverlay")).toBeHidden();
|
|
271
280
|
});
|
|
281
|
+
|
|
282
|
+
test("inactive and grouped tab actions keep setup, generation, and busy state scoped without activating the tab", async ({ page }) => {
|
|
283
|
+
const requests = { get: 0, put: [], generate: [] };
|
|
284
|
+
let releaseGeneration;
|
|
285
|
+
const generationReleased = new Promise((resolve) => { releaseGeneration = resolve; });
|
|
286
|
+
await installSummaryRoutes(page, requests, {
|
|
287
|
+
generate: async () => {
|
|
288
|
+
await generationReleased;
|
|
289
|
+
return generatedSummaryResponse();
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
await page.goto(baseURL);
|
|
293
|
+
await expect(page.locator(".terminal-tab[data-tab-id]").first()).toBeVisible();
|
|
294
|
+
const initialTabCount = await page.locator(".terminal-tab[data-tab-id]").count();
|
|
295
|
+
expect(initialTabCount).toBeGreaterThan(0);
|
|
296
|
+
await expect(page.locator(".terminal-tab-summary-button")).toHaveCount(initialTabCount);
|
|
297
|
+
|
|
298
|
+
const firstTabId = await page.locator(".terminal-tab[data-tab-id]").first().getAttribute("data-tab-id");
|
|
299
|
+
await page.locator("#newTabButton").evaluate((button) => button.click());
|
|
300
|
+
await page.locator("#newTabCurrentDirectoryButton").evaluate((button) => button.click());
|
|
301
|
+
const expectedTabCount = initialTabCount + 1;
|
|
302
|
+
await expect(page.locator(".terminal-tab[data-tab-id]")).toHaveCount(expectedTabCount);
|
|
303
|
+
await expect(page.locator(".terminal-tab-summary-button")).toHaveCount(expectedTabCount);
|
|
304
|
+
|
|
305
|
+
await page.reload();
|
|
306
|
+
await expect(page.locator(".terminal-tab[data-tab-id]")).toHaveCount(expectedTabCount);
|
|
307
|
+
await expect(page.locator(".terminal-tab-summary-button")).toHaveCount(expectedTabCount);
|
|
308
|
+
|
|
309
|
+
const activeTab = page.locator(".terminal-tab.active[data-tab-id]");
|
|
310
|
+
const activeTabId = await activeTab.getAttribute("data-tab-id");
|
|
311
|
+
expect(activeTabId).not.toBe(firstTabId);
|
|
312
|
+
const inactiveSummary = page.locator(`[data-tab-id="${firstTabId}"] > .terminal-tab-actions > .terminal-tab-summary-button`);
|
|
313
|
+
const activeSummary = page.locator(`[data-tab-id="${activeTabId}"] > .terminal-tab-actions > .terminal-tab-summary-button`);
|
|
314
|
+
await inactiveSummary.click();
|
|
315
|
+
await expect(page.locator("#nativeCommandDialog")).toBeVisible();
|
|
316
|
+
await expect(page.locator("#nativeCommandTitle")).toHaveText("/summary-setup");
|
|
317
|
+
await expect(page.locator(`[data-tab-id="${activeTabId}"]`)).toHaveClass(/active/);
|
|
318
|
+
|
|
319
|
+
await page.locator("#nativeCommandActions").getByRole("button", { name: "Save and generate" }).click();
|
|
320
|
+
await page.locator("#confirmationConfirmButton").click();
|
|
321
|
+
await expect.poll(() => requests.generate.length).toBe(1);
|
|
322
|
+
expect(requests.putTabs).toEqual([firstTabId]);
|
|
323
|
+
expect(requests.generateTabs).toEqual([firstTabId]);
|
|
324
|
+
await expect(inactiveSummary).toBeDisabled();
|
|
325
|
+
await expect(inactiveSummary).toHaveAttribute("aria-busy", "true");
|
|
326
|
+
await expect(activeSummary).toBeEnabled();
|
|
327
|
+
await expect(activeSummary).toHaveAttribute("aria-busy", "false");
|
|
328
|
+
await expect(page.locator(`[data-tab-id="${activeTabId}"]`)).toHaveClass(/active/);
|
|
329
|
+
|
|
330
|
+
releaseGeneration();
|
|
331
|
+
await expect(page.locator("#sessionSummaryOverlay")).toBeVisible();
|
|
332
|
+
await expect(page.locator("#sessionSummaryOverlayTitle")).toHaveText("Validated fixture title");
|
|
333
|
+
await expect(inactiveSummary).toBeEnabled();
|
|
334
|
+
await page.keyboard.press("Escape");
|
|
335
|
+
|
|
336
|
+
await page.locator(`.terminal-tab[data-tab-id="${activeTabId}"]`).dragTo(page.locator(`.terminal-tab[data-tab-id="${firstTabId}"]`));
|
|
337
|
+
const group = page.locator(".terminal-tab-custom-group");
|
|
338
|
+
await expect(group).toHaveCount(1);
|
|
339
|
+
await group.hover();
|
|
340
|
+
await expect(group.locator(".terminal-tab-group-item")).toHaveCount(2);
|
|
341
|
+
await expect(group.locator(".terminal-tab-group-item > .terminal-tab-actions > .terminal-tab-summary-button")).toHaveCount(2);
|
|
342
|
+
await group.locator(`[data-tab-id="${firstTabId}"] > .terminal-tab-actions > .terminal-tab-summary-button`).click();
|
|
343
|
+
await expect(page.locator("#sessionSummaryOverlayTitle")).toHaveText("Validated fixture title");
|
|
344
|
+
await expect(group.locator(`[data-tab-id="${activeTabId}"]`)).toHaveClass(/active/);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("focus returns to a regenerated per-tab summary action after tab controls rerender", async ({ page }) => {
|
|
348
|
+
const requests = { get: 0, put: [], generate: [] };
|
|
349
|
+
await installSummaryRoutes(page, requests, { configured: true });
|
|
350
|
+
await page.goto(baseURL);
|
|
351
|
+
|
|
352
|
+
await expect(page.locator("#promptInput")).toBeFocused();
|
|
353
|
+
const summaryButton = page.locator(".terminal-tab.active[data-tab-id] > .terminal-tab-actions > .terminal-tab-summary-button, .terminal-tab-group.active .terminal-tab-group-item.active > .terminal-tab-actions > .terminal-tab-summary-button");
|
|
354
|
+
await expect(summaryButton).toHaveCount(1);
|
|
355
|
+
await summaryButton.evaluate((button) => button.click());
|
|
356
|
+
await expect(page.locator("#sessionSummaryOverlayTitle")).toHaveText("Validated fixture title");
|
|
357
|
+
await page.keyboard.press("Escape");
|
|
358
|
+
await expect(summaryButton).toBeFocused();
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
test("each terminal tab stacks Split and Summary across one horizontally divided action slot", async ({ page }) => {
|
|
362
|
+
const requests = { get: 0, put: [], generate: [] };
|
|
363
|
+
await installSummaryRoutes(page, requests, { configured: true });
|
|
364
|
+
await page.goto(baseURL);
|
|
365
|
+
|
|
366
|
+
await expect(page.locator("#splitTabButton")).toHaveCount(0);
|
|
367
|
+
const initialTabCount = await page.locator("[data-tab-id] > .terminal-tab-actions").count();
|
|
368
|
+
const activeGroup = page.locator(".terminal-tab-group.active");
|
|
369
|
+
if (await activeGroup.count()) await activeGroup.hover();
|
|
370
|
+
const activeActions = page.locator(".terminal-tab.active[data-tab-id] > .terminal-tab-actions, .terminal-tab-group.active .terminal-tab-group-item.active > .terminal-tab-actions");
|
|
371
|
+
await expect(activeActions).toHaveCount(1);
|
|
372
|
+
await expect(activeActions.locator(":scope > .terminal-tab-split-button")).toHaveCount(1);
|
|
373
|
+
await expect(activeActions.locator(":scope > .terminal-tab-summary-button")).toHaveCount(1);
|
|
374
|
+
const actionGeometry = await activeActions.evaluate((slot) => ({
|
|
375
|
+
slotWidth: slot.getBoundingClientRect().width,
|
|
376
|
+
splitWidth: slot.querySelector(".terminal-tab-split-button")?.getBoundingClientRect().width || 0,
|
|
377
|
+
summaryWidth: slot.querySelector(".terminal-tab-summary-button")?.getBoundingClientRect().width || 0,
|
|
378
|
+
slotHeight: slot.getBoundingClientRect().height,
|
|
379
|
+
tabHeight: slot.parentElement?.querySelector(":scope > .terminal-tab-button")?.getBoundingClientRect().height || 0,
|
|
380
|
+
splitHeight: slot.querySelector(".terminal-tab-split-button")?.getBoundingClientRect().height || 0,
|
|
381
|
+
summaryHeight: slot.querySelector(".terminal-tab-summary-button")?.getBoundingClientRect().height || 0,
|
|
382
|
+
}));
|
|
383
|
+
expect(Math.abs(actionGeometry.splitWidth - actionGeometry.slotWidth)).toBeLessThanOrEqual(1);
|
|
384
|
+
expect(Math.abs(actionGeometry.summaryWidth - actionGeometry.slotWidth)).toBeLessThanOrEqual(1);
|
|
385
|
+
expect(Math.abs(actionGeometry.slotHeight - actionGeometry.tabHeight)).toBeLessThan(1);
|
|
386
|
+
expect(Math.abs(actionGeometry.splitHeight - actionGeometry.summaryHeight)).toBeLessThan(1);
|
|
387
|
+
expect(Math.abs((actionGeometry.splitHeight + actionGeometry.summaryHeight) - actionGeometry.slotHeight)).toBeLessThan(2);
|
|
388
|
+
|
|
389
|
+
await activeActions.locator(":scope > .terminal-tab-split-button").click();
|
|
390
|
+
await expect(page.locator("[data-tab-id] > .terminal-tab-actions")).toHaveCount(initialTabCount + 1);
|
|
391
|
+
await expect(page.locator("#terminalSplitShell")).toBeVisible();
|
|
392
|
+
const splitTabId = await page.locator("#terminalSplitFrame").getAttribute("data-tab-id");
|
|
393
|
+
expect(splitTabId).toBeTruthy();
|
|
394
|
+
const splitControl = page.locator(`[data-tab-id="${splitTabId}"] > .terminal-tab-actions > .terminal-tab-split-button`);
|
|
395
|
+
await expect(splitControl).toHaveAttribute("aria-pressed", "true");
|
|
396
|
+
await splitControl.evaluate((button) => button.click());
|
|
397
|
+
await expect(page.locator("#terminalSplitShell")).toBeHidden();
|
|
398
|
+
await expect(splitControl).toHaveAttribute("aria-pressed", "false");
|
|
399
|
+
});
|