Merge branch 'main' into web-chat-create
# Conflicts: # web/PARITY.md # web/src/app.js # web/test/chat.test.mjs # web/test/ui-smoke.mjs
This commit is contained in:
@@ -7,6 +7,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
BACKGROUND_TASKS_TITLE,
|
||||
BACKGROUND_TASK_VISIBLE_ROWS,
|
||||
CHAT_ACTIONS_LABEL,
|
||||
CHAT_COMMANDS,
|
||||
CHAT_COMMAND_DISMISS_LABEL,
|
||||
CHAT_COMMAND_FAILED_LABEL,
|
||||
@@ -20,7 +21,16 @@ import {
|
||||
CHAT_CREATE_PROMPT,
|
||||
CHAT_CREATE_TITLE,
|
||||
CHAT_FOLLOW_THRESHOLD_PX,
|
||||
CHAT_HIDE_ACTION,
|
||||
CHAT_QUEUED_NOTICE,
|
||||
CHAT_REMOVED_MESSAGE,
|
||||
CHAT_RENAME_ACTION,
|
||||
CHAT_RENAME_DISMISS,
|
||||
CHAT_RENAME_FIELD_LABEL,
|
||||
CHAT_RENAME_HELPER,
|
||||
CHAT_RENAME_SAVE,
|
||||
CHAT_RENAME_TITLE,
|
||||
CHAT_UNDO_ACTION,
|
||||
COMPOSER_SEND,
|
||||
COMPOSER_STOP,
|
||||
ChatTurn,
|
||||
@@ -60,6 +70,7 @@ import {
|
||||
TURN_THINKING_WINDOW_MILLIS,
|
||||
appendChatNotice,
|
||||
applyChatEvent,
|
||||
applyChatOverrides,
|
||||
applyChatPermission,
|
||||
approvalCard,
|
||||
approvalResources,
|
||||
@@ -83,6 +94,7 @@ import {
|
||||
chatNoMatchMessage,
|
||||
chatNoticeLabel,
|
||||
chatOpensAtNewest,
|
||||
chatSeenWatermark,
|
||||
chatShowJumpToLatest,
|
||||
chatStartInLabel,
|
||||
chatStreamState,
|
||||
@@ -92,17 +104,26 @@ import {
|
||||
composerSendEnabled,
|
||||
composerSubmit,
|
||||
decisionLabel,
|
||||
decodeChatOverrides,
|
||||
decodeChatSeen,
|
||||
defaultDirectoryChoice,
|
||||
deltaPartId,
|
||||
directoryChoices,
|
||||
directoryLabel,
|
||||
dismissChatNotice,
|
||||
emptyChatOverrides,
|
||||
emptyChatSeen,
|
||||
encodeChatOverrides,
|
||||
encodeChatSeen,
|
||||
filterSessions,
|
||||
formatToolDuration,
|
||||
groupSessionsByDirectory,
|
||||
hideChatOverride,
|
||||
historyResync,
|
||||
isChatSessionUnseen,
|
||||
lineDiff,
|
||||
makeChatNotice,
|
||||
markChatUnseen,
|
||||
mergeHistoryPage,
|
||||
mergeShellFrame,
|
||||
mergeToolPart,
|
||||
@@ -113,12 +134,16 @@ import {
|
||||
permissionRiskText,
|
||||
prettyToolInput,
|
||||
queuedAfterFrame,
|
||||
readChatSeen,
|
||||
reasoningLabel,
|
||||
renameChatOverride,
|
||||
restoreChatOverride,
|
||||
resumedThread,
|
||||
runningAfterFrame,
|
||||
runningBackgroundShells,
|
||||
runningToolElapsedMillis,
|
||||
runningToolStamps,
|
||||
seedChatSeen,
|
||||
selectChatDirectory,
|
||||
sessionActivity,
|
||||
sessionActivityBadge,
|
||||
@@ -1741,3 +1766,169 @@ test("the create flow's wording is the app's verbatim", () => {
|
||||
assert.equal(chatStartInLabel(HOME_DIRECTORY), "Start in ~");
|
||||
assert.equal(chatStartInLabel("/repo/a"), "Start in /repo/a");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// C13: the local overrides and the seen state (ChatOverrides.kt / ChatSeen.kt)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const sess = (id, title, updated_at) => ({ id, title, updated_at });
|
||||
|
||||
test("local overrides: a local title wins on every refresh, trimmed, blanks ignored", () => {
|
||||
const sessions = [sess("a", "Server A", 100), sess("b", "Server B", 200)];
|
||||
|
||||
// No overrides: the server's own list is returned untouched.
|
||||
assert.equal(applyChatOverrides(sessions, emptyChatOverrides()), sessions);
|
||||
|
||||
let overrides = renameChatOverride(emptyChatOverrides(), "a", " My A ");
|
||||
assert.deepEqual(overrides.titles, { a: "My A" });
|
||||
const applied = applyChatOverrides(sessions, overrides);
|
||||
assert.equal(applied[0].title, "My A");
|
||||
assert.equal(applied[1].title, "Server B");
|
||||
// A later refresh (the server's own title still "Server A") keeps the local name.
|
||||
assert.equal(applyChatOverrides(sessions, overrides)[0].title, "My A");
|
||||
|
||||
// A blank id or a blank/whitespace title changes nothing (identity preserved).
|
||||
assert.equal(renameChatOverride(overrides, "a", " "), overrides);
|
||||
assert.equal(renameChatOverride(overrides, " ", "Nope"), overrides);
|
||||
// A rename for another id is recorded without touching the first.
|
||||
const both = renameChatOverride(overrides, "b", "Bee");
|
||||
assert.deepEqual(both.titles, { a: "My A", b: "Bee" });
|
||||
assert.equal(applyChatOverrides(sessions, both)[1].title, "Bee");
|
||||
// Re-recording the same trimmed title is a no-op (same object).
|
||||
assert.equal(renameChatOverride(both, "b", " Bee "), both);
|
||||
});
|
||||
|
||||
test("hide + undo: one entry per id, blank ignored, restore returns the prior state", () => {
|
||||
const overrides = emptyChatOverrides();
|
||||
const hidden = hideChatOverride(overrides, "s1");
|
||||
assert.deepEqual(hidden.hidden, ["s1"]);
|
||||
// Already hidden: nothing changes, and no duplicate is appended.
|
||||
assert.equal(hideChatOverride(hidden, "s1"), hidden);
|
||||
assert.equal(hideChatOverride(hidden, " "), hidden);
|
||||
|
||||
const sessions = [sess("s1", "One", 1), sess("s2", "Two", 2)];
|
||||
assert.deepEqual(applyChatOverrides(sessions, hidden).map((s) => s.id), ["s2"]);
|
||||
|
||||
const restored = restoreChatOverride(hidden, "s1");
|
||||
assert.deepEqual(restored.hidden, []);
|
||||
assert.deepEqual(applyChatOverrides(sessions, restored).map((s) => s.id), ["s1", "s2"]);
|
||||
// Restoring something that was never hidden changes nothing.
|
||||
assert.equal(restoreChatOverride(restored, "s9"), restored);
|
||||
// Hide then undo returns the original model.
|
||||
assert.deepEqual(restoreChatOverride(hideChatOverride(overrides, "s1"), "s1"), overrides);
|
||||
});
|
||||
|
||||
test("overrides JSON round-trips, and unreadable/wrong-typed input decodes to empty", () => {
|
||||
const overrides = renameChatOverride(hideChatOverride(emptyChatOverrides(), "gone"), "kept", "Name");
|
||||
assert.deepEqual(decodeChatOverrides(encodeChatOverrides(overrides)), overrides);
|
||||
|
||||
for (const corrupt of [null, "", "not json", "{", "[]", '"x"', "42"]) {
|
||||
assert.deepEqual(decodeChatOverrides(corrupt), emptyChatOverrides());
|
||||
}
|
||||
// Wrong-typed fields fall back to the empty model rather than throwing.
|
||||
assert.deepEqual(decodeChatOverrides('{"titles":[],"hidden":"x"}'), emptyChatOverrides());
|
||||
assert.deepEqual(decodeChatOverrides('{"titles":{"a":3},"hidden":[7,"ok","ok"]}').hidden, ["ok"]);
|
||||
assert.deepEqual(decodeChatOverrides('{"titles":{"":"x","b":" B "}}'), { titles: { b: "B" }, hidden: [] });
|
||||
});
|
||||
|
||||
test("seen JSON round-trips, de-duplicates unseen, and tolerates corrupt input", () => {
|
||||
let seen = markChatUnseen(emptyChatSeen(), "s1");
|
||||
seen = markChatUnseen(seen, "s1"); // duplicate
|
||||
seen = readChatSeen(seen, "s2", 500);
|
||||
const decoded = decodeChatSeen(encodeChatSeen(seen));
|
||||
assert.deepEqual(decoded.seenAt, { s2: 500 });
|
||||
assert.deepEqual(decoded.unseen, ["s1"]);
|
||||
|
||||
for (const corrupt of [null, "", "not json", "{", "[]", "true"]) {
|
||||
assert.deepEqual(decodeChatSeen(corrupt), emptyChatSeen());
|
||||
}
|
||||
assert.deepEqual(decodeChatSeen('{"seenAt":[],"unseen":"x"}'), emptyChatSeen());
|
||||
const tolerated = decodeChatSeen('{"seenAt":{"a":10,"b":"x","":5},"unseen":["u","u",""]}');
|
||||
assert.deepEqual(tolerated.seenAt, { a: 10 });
|
||||
assert.deepEqual(tolerated.unseen, ["u"]);
|
||||
});
|
||||
|
||||
test("first sight seeding: a baseline is set once and never clears an explicit unseen", () => {
|
||||
const sessions = [sess("a", "A", 100), sess("b", "B", 0)];
|
||||
const seeded = seedChatSeen(emptyChatSeen(), sessions, null);
|
||||
assert.deepEqual(seeded.seenAt, { a: 100 });
|
||||
// An absent or zero recency is never recorded.
|
||||
assert.equal(seeded.seenAt.b, undefined);
|
||||
// A later, higher recency is not re-seeded over the existing baseline.
|
||||
const later = seedChatSeen(seeded, [sess("a", "A", 300)], null);
|
||||
assert.deepEqual(later.seenAt, { a: 100 });
|
||||
|
||||
// Seeding never clears an unseen mark.
|
||||
const marked = markChatUnseen(seeded, "a");
|
||||
const reseeded = seedChatSeen(marked, [sess("a", "A", 400)], null);
|
||||
assert.deepEqual(reseeded.unseen, ["a"]);
|
||||
|
||||
// The active session is read (watermark advances, the mark clears).
|
||||
const active = seedChatSeen(markChatUnseen(emptyChatSeen(), "a"), [sess("a", "A", 900)], "a");
|
||||
assert.deepEqual(active.seenAt, { a: 900 });
|
||||
assert.deepEqual(active.unseen, []);
|
||||
});
|
||||
|
||||
test("reading advances the watermark monotonically and always clears the mark", () => {
|
||||
const first = readChatSeen(emptyChatSeen(), "s", 100);
|
||||
assert.equal(chatSeenWatermark(first, "s"), 100);
|
||||
// A stale read cannot rewind it...
|
||||
assert.equal(readChatSeen(first, "s", 50), first);
|
||||
// ...an equal read is not "newer" either...
|
||||
assert.equal(readChatSeen(first, "s", 100), first);
|
||||
// ...but a strictly newer one advances.
|
||||
assert.equal(chatSeenWatermark(readChatSeen(first, "s", 101), "s"), 101);
|
||||
|
||||
// A mark is cleared even when the recency does not advance.
|
||||
const marked = markChatUnseen(first, "s");
|
||||
const read = readChatSeen(marked, "s", 100);
|
||||
assert.deepEqual(read.unseen, []);
|
||||
assert.equal(read.seenAt.s, 100);
|
||||
// A blank id is a no-op.
|
||||
assert.equal(readChatSeen(first, " ", 500), first);
|
||||
});
|
||||
|
||||
test("the unseen rule: not active, explicit mark or never-opened-and-strictly-newer", () => {
|
||||
let seen = readChatSeen(emptyChatSeen(), "opened", 100);
|
||||
seen = readChatSeen(seen, "equal", 100);
|
||||
// A watermark ahead of the session's own recency: not newer, so not new.
|
||||
seen = readChatSeen(seen, "old", 120);
|
||||
const opened = sess("opened", "Opened", 200); // moved on after it was read
|
||||
const fresh = sess("fresh", "Fresh", 150);
|
||||
const equal = sess("equal", "Equal", 100);
|
||||
const old = sess("old", "Old", 50);
|
||||
|
||||
// The active session is never new, even with an explicit mark.
|
||||
assert.equal(
|
||||
isChatSessionUnseen(opened, { activeId: "opened", seen: markChatUnseen(seen, "opened"), opened: true }),
|
||||
false,
|
||||
);
|
||||
// A never-opened session is new only while strictly newer than the watermark.
|
||||
assert.equal(isChatSessionUnseen(fresh, { seen, opened: false }), true);
|
||||
assert.equal(isChatSessionUnseen(equal, { seen, opened: false }), false);
|
||||
assert.equal(isChatSessionUnseen(old, { seen, opened: false }), false);
|
||||
// A session already opened here is judged by the explicit mark alone.
|
||||
assert.equal(isChatSessionUnseen(opened, { seen, opened: true }), false);
|
||||
assert.equal(isChatSessionUnseen(opened, { seen: markChatUnseen(seen, "opened"), opened: true }), true);
|
||||
});
|
||||
|
||||
test("the C13 wording matches the Android sources verbatim", () => {
|
||||
assert.equal(CHAT_RENAME_ACTION, "Rename…");
|
||||
assert.equal(CHAT_HIDE_ACTION, "Hide on this device");
|
||||
assert.equal(CHAT_ACTIONS_LABEL, "Chat actions");
|
||||
assert.equal(CHAT_REMOVED_MESSAGE, "Hidden on this device; the chat stays on the server.");
|
||||
assert.equal(CHAT_UNDO_ACTION, "Undo");
|
||||
assert.equal(CHAT_RENAME_TITLE, "Rename chat");
|
||||
assert.equal(CHAT_RENAME_FIELD_LABEL, "Name");
|
||||
assert.equal(
|
||||
CHAT_RENAME_HELPER,
|
||||
"The server has no rename for a chat, so this name is kept on this device.",
|
||||
);
|
||||
assert.equal(CHAT_RENAME_SAVE, "Save");
|
||||
assert.equal(CHAT_RENAME_DISMISS, "Cancel");
|
||||
// The badge precedence words, with Open only while the conversation is open.
|
||||
assert.equal(sessionActivityBadge(sessionActivity(true, true), true), "Streaming");
|
||||
assert.equal(sessionActivityBadge(sessionActivity(false, true), true), "New");
|
||||
assert.equal(sessionActivityBadge(sessionActivity(false, false), true), "Open");
|
||||
assert.equal(sessionActivityBadge(sessionActivity(false, false), false), null);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
// The pure notification model (L5): qualifying transitions, exactly-once
|
||||
// dedupe, pre-existing/dismissed suppression, the app's exact wording and the
|
||||
// total permission/storage helpers. No DOM, no timer, no live server.
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { AttentionKind, attentionKey } from "../src/attention.js";
|
||||
import {
|
||||
NOTIFICATION_DEFAULT,
|
||||
NOTIFICATION_DEFAULT_ASKED,
|
||||
NOTIFICATION_DENIED,
|
||||
NOTIFICATION_GRANTED,
|
||||
NOTIFICATION_INSECURE,
|
||||
NOTIFICATION_UNSUPPORTED,
|
||||
NOTIFY_STORAGE_KEY,
|
||||
alertBody,
|
||||
alertKey,
|
||||
alertTitle,
|
||||
createAlertLedger,
|
||||
decodeNotificationSettings,
|
||||
encodeNotificationSettings,
|
||||
notificationEnvironment,
|
||||
notificationPermissionState,
|
||||
} from "../src/notify.js";
|
||||
|
||||
const frame = (runId, status, extra = {}) => ({
|
||||
run_id: runId,
|
||||
status,
|
||||
name: "release",
|
||||
title: "Ship it",
|
||||
...extra,
|
||||
});
|
||||
|
||||
test("headlines are exactly the app's two, and unknown kinds are blank", () => {
|
||||
assert.equal(alertTitle(AttentionKind.Failed), "A run failed");
|
||||
assert.equal(alertTitle(AttentionKind.Decision), "A run needs your decision");
|
||||
assert.equal(alertTitle({ name: "Failed" }), "A run failed");
|
||||
assert.equal(alertTitle({ name: "Other" }), "");
|
||||
});
|
||||
|
||||
test("the alert identity is the attention identity", () => {
|
||||
assert.equal(alertKey(7, AttentionKind.Failed), attentionKey(7, AttentionKind.Failed));
|
||||
assert.equal(alertKey(7, AttentionKind.Decision), "7:Decision");
|
||||
});
|
||||
|
||||
test("alert body is the title then the pipeline, with the pipeline fallback", () => {
|
||||
assert.equal(alertBody({ label: "Ship it", pipeline: "release" }), "Ship it \u00b7 release");
|
||||
assert.equal(alertBody({ title: " Ship it ", name: "release" }), "Ship it \u00b7 release");
|
||||
assert.equal(alertBody({ title: " ", name: "release" }), "release");
|
||||
assert.equal(alertBody({ label: "release", pipeline: "release" }), "release");
|
||||
assert.equal(alertBody({ label: "Ship it", pipeline: "" }), "Ship it");
|
||||
assert.equal(alertBody(frame(7, "failed")), "Ship it \u00b7 release");
|
||||
});
|
||||
|
||||
test("queued -> failed raises one alert and duplicate frames never repeat it", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 4, status: "queued", name: "release", title: "Ship it" }]);
|
||||
const alert = ledger.observe(frame(4, "failed"));
|
||||
assert.equal(alert.title, "A run failed");
|
||||
assert.equal(alert.body, "Ship it \u00b7 release");
|
||||
assert.equal(alert.key, "4:Failed");
|
||||
assert.equal(ledger.observe(frame(4, "failed")), null);
|
||||
assert.equal(ledger.observe(frame(4, "failed")), null);
|
||||
});
|
||||
|
||||
test("running -> waiting raises the decision alert; unchanged waiting raises none", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 9, status: "running", name: "release", title: "Ship it" }]);
|
||||
const alert = ledger.observe(frame(9, "waiting"));
|
||||
assert.equal(alert.title, "A run needs your decision");
|
||||
assert.equal(alert.key, "9:Decision");
|
||||
assert.equal(ledger.observe(frame(9, "waiting")), null);
|
||||
});
|
||||
|
||||
test("succeeded, canceled, interrupted and unknown statuses raise nothing", () => {
|
||||
for (const status of ["succeeded", "canceled", "interrupted", "mystery", ""]) {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 11, status: "running" }]);
|
||||
assert.equal(ledger.observe(frame(11, status)), null, `status ${status}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("a first-seen failed/waiting run (a snapshot seed) raises nothing", () => {
|
||||
const ledger = createAlertLedger();
|
||||
assert.equal(ledger.observe(frame(21, "failed")), null);
|
||||
assert.equal(ledger.observe(frame(22, "waiting")), null);
|
||||
});
|
||||
|
||||
test("a run already failed/waiting in the seed raises nothing", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([
|
||||
{ id: 31, status: "failed" },
|
||||
{ id: 32, status: "waiting" },
|
||||
]);
|
||||
assert.equal(ledger.observe(frame(31, "failed")), null);
|
||||
assert.equal(ledger.observe(frame(32, "waiting")), null);
|
||||
});
|
||||
|
||||
test("the subscribe snapshot is seeded, so a queued run that failed in the gap does not notify", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 41, status: "queued" }]);
|
||||
ledger.beginSeed();
|
||||
assert.equal(ledger.observe(frame(41, "failed")), null);
|
||||
ledger.endSeed();
|
||||
assert.equal(ledger.observe(frame(41, "failed")), null);
|
||||
// A later real transition still raises exactly once.
|
||||
assert.equal(ledger.observe(frame(41, "running")), null);
|
||||
assert.equal(ledger.observe(frame(41, "failed")).key, "41:Failed");
|
||||
});
|
||||
|
||||
test("leaving the qualifying state forgets the key for a genuinely new transition", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 51, status: "queued" }]);
|
||||
assert.equal(ledger.observe(frame(51, "failed")).key, "51:Failed");
|
||||
assert.equal(ledger.observe(frame(51, "running")), null);
|
||||
assert.equal(ledger.observe(frame(51, "failed")).key, "51:Failed");
|
||||
// And a failed -> waiting hand-off raises the other kind once.
|
||||
assert.equal(ledger.observe(frame(51, "waiting")).key, "51:Decision");
|
||||
assert.equal(ledger.observe(frame(51, "waiting")), null);
|
||||
});
|
||||
|
||||
test("a dismissed attention key notifies nothing, even on a real transition", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 61, status: "queued" }]);
|
||||
const alert = ledger.observe(frame(61, "failed"), {
|
||||
dismissed: new Set([attentionKey(61, AttentionKind.Failed)]),
|
||||
});
|
||||
assert.equal(alert, null);
|
||||
assert.deepEqual(ledger.notifiedKeys(), ["61:Failed"]);
|
||||
});
|
||||
|
||||
test("reset drops the status baseline but keeps the page session's dedupe", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 71, status: "queued" }]);
|
||||
assert.equal(ledger.observe(frame(71, "failed")).key, "71:Failed");
|
||||
ledger.reset();
|
||||
// Re-seeding the fresh (still failed) list is not a transition.
|
||||
ledger.seed([{ id: 71, status: "failed" }]);
|
||||
assert.equal(ledger.observe(frame(71, "failed")), null);
|
||||
assert.deepEqual(ledger.notifiedKeys(), ["71:Failed"]);
|
||||
});
|
||||
|
||||
test("a malformed frame is ignored, never crashed on", () => {
|
||||
const ledger = createAlertLedger();
|
||||
assert.equal(ledger.observe(null), null);
|
||||
assert.equal(ledger.observe({}), null);
|
||||
assert.equal(ledger.observe({ run_id: 0, status: "failed" }), null);
|
||||
});
|
||||
|
||||
test("permission wording is honest for every browser state", () => {
|
||||
assert.equal(notificationPermissionState({ supported: false }).body, NOTIFICATION_UNSUPPORTED);
|
||||
assert.equal(
|
||||
notificationPermissionState({ supported: true, secureContext: false }).body,
|
||||
NOTIFICATION_INSECURE,
|
||||
);
|
||||
assert.equal(notificationPermissionState({ permission: "denied" }).body, NOTIFICATION_DENIED);
|
||||
assert.equal(notificationPermissionState({ permission: "granted" }).body, NOTIFICATION_GRANTED);
|
||||
assert.equal(notificationPermissionState({ asked: false }).body, NOTIFICATION_DEFAULT);
|
||||
assert.equal(notificationPermissionState({ asked: true }).body, NOTIFICATION_DEFAULT_ASKED);
|
||||
});
|
||||
|
||||
test("only a supported, secure default permission offers the request control", () => {
|
||||
const defaultView = notificationPermissionState({ asked: false });
|
||||
assert.equal(defaultView.state, "default");
|
||||
assert.equal(defaultView.canRequest, true);
|
||||
assert.equal(defaultView.actionLabel, "Enable notifications");
|
||||
|
||||
for (const options of [
|
||||
{ supported: false },
|
||||
{ supported: true, secureContext: false },
|
||||
{ permission: "granted" },
|
||||
{ permission: "denied" },
|
||||
]) {
|
||||
const view = notificationPermissionState(options);
|
||||
assert.equal(view.canRequest, false, JSON.stringify(options));
|
||||
assert.equal(view.actionLabel, null, JSON.stringify(options));
|
||||
}
|
||||
// Having been asked once does not remove the control while permission stays
|
||||
// default (the browser itself decides whether it may prompt again).
|
||||
assert.equal(notificationPermissionState({ asked: true }).canRequest, true);
|
||||
});
|
||||
|
||||
test("the asked flag round-trips and malformed storage decodes safely", () => {
|
||||
assert.equal(NOTIFY_STORAGE_KEY, "pipelines.web.notify.v1");
|
||||
const stored = encodeNotificationSettings({ asked: true });
|
||||
assert.deepEqual(JSON.parse(stored), { asked: true });
|
||||
assert.equal(decodeNotificationSettings(stored).asked, true);
|
||||
assert.equal(decodeNotificationSettings(encodeNotificationSettings({ asked: false })).asked, false);
|
||||
|
||||
for (const bad of ["", " ", "not json", "[]", "null", '"asked"', "{", '{"asked":"yes"}', "42"]) {
|
||||
assert.deepEqual(decodeNotificationSettings(bad), { asked: false }, bad);
|
||||
}
|
||||
assert.deepEqual(decodeNotificationSettings(null), { asked: false });
|
||||
});
|
||||
|
||||
test("notificationEnvironment reads the browser facts without guessing", () => {
|
||||
const granted = notificationEnvironment({
|
||||
Notification: Object.assign(function Notification() {}, { permission: "granted" }),
|
||||
isSecureContext: true,
|
||||
});
|
||||
assert.deepEqual(granted, { supported: true, secureContext: true, permission: "granted" });
|
||||
|
||||
assert.deepEqual(notificationEnvironment({}), {
|
||||
supported: false,
|
||||
secureContext: false,
|
||||
permission: "default",
|
||||
});
|
||||
|
||||
const odd = notificationEnvironment({
|
||||
Notification: Object.assign(function Notification() {}, { permission: "maybe" }),
|
||||
isSecureContext: false,
|
||||
});
|
||||
assert.deepEqual(odd, { supported: true, secureContext: false, permission: "default" });
|
||||
});
|
||||
@@ -293,6 +293,30 @@ test("a run action throws when the reply has no run detail", async () => {
|
||||
await assert.rejects(() => repo.cancelRun(7), ProtocolError);
|
||||
});
|
||||
|
||||
test("subscribeRuns sends exactly the blank any-workspace watch and no run_ids", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "subscribe" });
|
||||
|
||||
await repo.subscribeRuns();
|
||||
assert.deepEqual(lastFrame(ws), { type: "subscribe", workspace: "" });
|
||||
});
|
||||
|
||||
test("unsubscribeRuns sends exactly {type:'unsubscribe'}", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "unsubscribe" });
|
||||
|
||||
await repo.unsubscribeRuns();
|
||||
assert.deepEqual(lastFrame(ws), { type: "unsubscribe" });
|
||||
});
|
||||
|
||||
test("subscribeRuns is not sent while the page is not connected", async () => {
|
||||
FakeWebSocket.instances = [];
|
||||
const client = new PipelinesClient({ WebSocketImpl: FakeWebSocket });
|
||||
const repo = new PipelinesRepository(client);
|
||||
await assert.rejects(() => repo.subscribeRuns(), { name: "NotConnectedError" });
|
||||
assert.equal(FakeWebSocket.instances.length, 0);
|
||||
});
|
||||
|
||||
// ---- The composer's own commands (C8/C9) ----------------------------------
|
||||
|
||||
test("chatPrompt trims the text, sends the operation and native message ids, and omits files when empty", async () => {
|
||||
|
||||
+592
-25
@@ -2,7 +2,9 @@
|
||||
// Chrome, connect to a running Pipelines server through the page's own proxy,
|
||||
// and capture what actually rendered.
|
||||
//
|
||||
// node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR] [--scratch]
|
||||
// node test/ui-smoke.mjs [--port PORT] [--pipelines 127.0.0.1:8080] [--out DIR] [--scratch]
|
||||
//
|
||||
// Without --port the OS picks a free port, so concurrent checks do not collide.
|
||||
//
|
||||
// This is the UI evidence a review stage produces: real screenshots of the
|
||||
// rendered client, not a claim. It needs a running Pipelines server (the live one
|
||||
@@ -32,6 +34,12 @@ import {
|
||||
WORKSPACE_PLACEHOLDER,
|
||||
WORKSPACE_STORAGE_KEY,
|
||||
} from "../src/settings.js";
|
||||
import {
|
||||
NOTIFICATION_DEFAULT,
|
||||
NOTIFICATION_DENIED,
|
||||
NOTIFICATION_GRANTED,
|
||||
NOTIFY_STORAGE_KEY,
|
||||
} from "../src/notify.js";
|
||||
|
||||
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
|
||||
@@ -51,7 +59,12 @@ function flag(argv, name, fallback) {
|
||||
return i !== -1 && argv[i + 1] ? argv[i + 1] : fallback;
|
||||
}
|
||||
|
||||
const port = Number(flag(process.argv, "--port", process.env.WEB_UI_PORT ?? 8091));
|
||||
// No fixed default port: an explicit --port/WEB_UI_PORT still wins, but otherwise
|
||||
// each run asks the OS for a free one. Concurrent checks (parallel pipeline items)
|
||||
// therefore never collide on 8091 — the earlier fixed default made a second
|
||||
// simultaneous UI stage fail with EADDRINUSE.
|
||||
const explicitPort = flag(process.argv, "--port", process.env.WEB_UI_PORT);
|
||||
const port = explicitPort ? Number(explicitPort) : await freePort();
|
||||
const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET ?? "127.0.0.1:8080");
|
||||
const out = resolve(
|
||||
flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")),
|
||||
@@ -59,6 +72,8 @@ const out = resolve(
|
||||
// Scratch mode: only the P5 create-from-template flow runs, against a throwaway
|
||||
// server with its own database. The default (live) run sends no submit.
|
||||
const scratch = process.argv.includes("--scratch");
|
||||
// Focused notification evidence only; skips the unrelated live-suite steps.
|
||||
const notifyOnly = process.argv.includes("--notify");
|
||||
|
||||
// The page must connect through its own proxy (the server rejects a cross-origin
|
||||
// upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL
|
||||
@@ -161,6 +176,16 @@ async function openRunDetail(runId) {
|
||||
}
|
||||
}
|
||||
|
||||
// Open one chat row's Chat actions menu (the row's management items live behind
|
||||
// it since C13: Rename… / Close chat… or Reopen / Hide on this device).
|
||||
async function openChatRowMenu(sessionId) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
|
||||
await page.waitForSelector(
|
||||
`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel`,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
}
|
||||
|
||||
// --- P5: create a pipeline from a template (scratch server only) -----------
|
||||
// The scratch server has no real runs and no live chat, so this is the whole
|
||||
// point of a `--scratch` run. It opens a template, opens the create action,
|
||||
@@ -375,6 +400,225 @@ const drag = (dx, dy) =>
|
||||
return true;
|
||||
})()`);
|
||||
|
||||
// L5: the notification Settings states and the synthetic transition assertions.
|
||||
// Extracted so `--notify` can run exactly this evidence without the unrelated
|
||||
// live-suite steps; the default full run calls it in its L1/L5 position.
|
||||
async function runNotificationChecks() {
|
||||
// L5: notifications. A real OS notification cannot be captured reliably in
|
||||
// headless Chrome, so the browser's Notification constructor is stubbed and
|
||||
// recorded before this document loads; the qualifying transitions are then
|
||||
// pushed through the page's own socket `onmessage`/`frame` path and matched
|
||||
// against the pure ledger's decisions. The Settings states are real renders.
|
||||
// The stub also pre-dismisses one synthetic run+kind so suppression is proven
|
||||
// through the same attention identity the page loads at boot.
|
||||
step("L5: notification settings and synthetic run transitions");
|
||||
await page.addInitScript(`(() => {
|
||||
if (window.__notificationStubInstalled) return;
|
||||
window.__notificationStubInstalled = true;
|
||||
window.__notificationCalls = [];
|
||||
window.__notificationObjects = [];
|
||||
window.__notificationRequests = 0;
|
||||
window.__notificationPermission = "default";
|
||||
function FakeNotification(title, options) {
|
||||
const call = {
|
||||
title: String(title),
|
||||
body: String(options && options.body != null ? options.body : ""),
|
||||
tag: String(options && options.tag != null ? options.tag : ""),
|
||||
};
|
||||
window.__notificationCalls.push(call);
|
||||
window.__notificationObjects.push(this);
|
||||
this.title = call.title;
|
||||
this.body = call.body;
|
||||
this.tag = call.tag;
|
||||
this.onclick = null;
|
||||
this.close = function () {};
|
||||
}
|
||||
Object.defineProperty(FakeNotification, "permission", {
|
||||
configurable: true,
|
||||
get: function () { return window.__notificationPermission; },
|
||||
});
|
||||
FakeNotification.requestPermission = function () {
|
||||
window.__notificationRequests += 1;
|
||||
window.__notificationPermission = "granted";
|
||||
return Promise.resolve("granted");
|
||||
};
|
||||
Object.defineProperty(window, "Notification", {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: FakeNotification,
|
||||
});
|
||||
localStorage.setItem("pipelines.web.attention.v1", JSON.stringify(["990001:Failed"]));
|
||||
})()`);
|
||||
await page.evaluate(`location.reload()`);
|
||||
await page.waitForSelector("#url", { timeout: 15000 });
|
||||
await page.fill("#url", `ws://127.0.0.1:${port}/connect`);
|
||||
await page.click("#connectBtn");
|
||||
await page.waitForSelector(".conn-banner.conn-ok", { timeout: 25000 });
|
||||
// The watch is sent once per connected epoch, after the list has seeded the
|
||||
// ledger. Wait for that send (and its ack continuation) so the synthetic
|
||||
// frames below are observed as deltas rather than as part of the snapshot.
|
||||
await eventually(
|
||||
() => page.evaluate(`(window.__pipelinesSentTypes || []).includes("subscribe")`),
|
||||
{ timeout: 15000, what: "the run-event subscribe frame" },
|
||||
);
|
||||
await page.evaluate(`new Promise((resolve) => setTimeout(resolve, 250))`);
|
||||
await page.clickText("nav.tabs button.tab", "Settings");
|
||||
await page.waitForSelector("#settingsNotificationState", { timeout: 15000 });
|
||||
|
||||
// Default state: honest wording, one explicit control, and nothing asked on
|
||||
// load or on connect.
|
||||
const defaultNotificationState = await text("#settingsNotificationState");
|
||||
if (defaultNotificationState !== NOTIFICATION_DEFAULT) {
|
||||
throw new Error(`default notification copy: ${defaultNotificationState}`);
|
||||
}
|
||||
const notificationsOnLoad = await page.evaluate(`window.__notificationRequests`);
|
||||
if (notificationsOnLoad !== 0) {
|
||||
throw new Error(`the page requested notification permission on load: ${notificationsOnLoad}`);
|
||||
}
|
||||
const enableControl = await page.evaluate(
|
||||
`document.querySelector("#settingsEnableNotifications")?.textContent ?? ""`,
|
||||
);
|
||||
if (enableControl !== "Enable notifications") {
|
||||
throw new Error(`notification request control: ${enableControl}`);
|
||||
}
|
||||
await page.evaluate(`document.querySelector("#settingsNotifications")?.scrollIntoView({ block: "center" })`);
|
||||
await shot("L5-notifications-settings.png");
|
||||
console.log(` notifications default: "${defaultNotificationState}" (0 permission requests on load)`);
|
||||
|
||||
// The explicit control grants through the stub; the page must remember that it
|
||||
// asked and stop offering the control.
|
||||
await page.click("#settingsEnableNotifications");
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector("#settingsNotificationState")?.textContent === ${JSON.stringify(NOTIFICATION_GRANTED)}`),
|
||||
{ timeout: 10000, what: "the granted notification wording" },
|
||||
);
|
||||
const grantState = await page.evaluate(`({
|
||||
requests: window.__notificationRequests,
|
||||
stored: localStorage.getItem(${JSON.stringify(NOTIFY_STORAGE_KEY)}),
|
||||
control: !!document.querySelector("#settingsEnableNotifications"),
|
||||
})`);
|
||||
if (grantState.requests !== 1 || grantState.control) {
|
||||
throw new Error(`grant state: ${JSON.stringify(grantState)}`);
|
||||
}
|
||||
if (grantState.stored !== JSON.stringify({ asked: true })) {
|
||||
throw new Error(`asked flag not stored: ${grantState.stored}`);
|
||||
}
|
||||
await page.evaluate(`document.querySelector("#settingsNotifications")?.scrollIntoView({ block: "center" })`);
|
||||
await shot("L5-notifications-granted.png");
|
||||
console.log(` notifications granted after one explicit click; asked=${grantState.stored}`);
|
||||
|
||||
// Drive the real frame path. The run id is a real run so the notification's
|
||||
// click can open it through the page's existing Runs navigation (L6 is todo).
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await page.waitForSelector(".list.runs .run-row-meta[data-run-id]", { timeout: 25000 });
|
||||
const realRunId = await page.evaluate(
|
||||
`Number(document.querySelector(".list.runs .run-row-meta[data-run-id]")?.getAttribute("data-run-id"))`,
|
||||
);
|
||||
if (!(realRunId > 0)) throw new Error(`no real run id for the notification click: ${realRunId}`);
|
||||
const runFrame = (runId, status, extra = {}) => ({
|
||||
run_id: runId,
|
||||
status,
|
||||
name: "Smoke pipeline",
|
||||
title: "Smoke run",
|
||||
...extra,
|
||||
});
|
||||
const replayRunEvents = (frames) =>
|
||||
page.evaluate(`(() => {
|
||||
const ws = window.__pipelinesSocket;
|
||||
if (!ws || typeof ws.onmessage !== "function") return false;
|
||||
for (const frame of ${JSON.stringify(frames)}) {
|
||||
ws.onmessage({ data: JSON.stringify({ type: "run_event", run_event: frame }) });
|
||||
}
|
||||
return true;
|
||||
})()`);
|
||||
const notificationCount = () => page.evaluate(`window.__notificationCalls.length`);
|
||||
const notifications = () => page.evaluate(`window.__notificationCalls`);
|
||||
|
||||
// queued -> failed raises exactly one; duplicate/terminal/unknown frames add none.
|
||||
if (!(await replayRunEvents([runFrame(realRunId, "queued")]))) {
|
||||
throw new Error("L5: the socket shim did not expose the live socket for run events");
|
||||
}
|
||||
await replayRunEvents([runFrame(realRunId, "failed")]);
|
||||
if ((await notificationCount()) !== 1) {
|
||||
throw new Error(`queued->failed should notify once: ${JSON.stringify(await notifications())}`);
|
||||
}
|
||||
const failedAlert = (await notifications())[0];
|
||||
const failedTag = `${realRunId}:Failed`;
|
||||
if (
|
||||
failedAlert.title !== "A run failed" ||
|
||||
failedAlert.body !== "Smoke run \u00b7 Smoke pipeline" ||
|
||||
failedAlert.tag !== failedTag
|
||||
) {
|
||||
throw new Error(`failed alert wording/tag: ${JSON.stringify(failedAlert)}`);
|
||||
}
|
||||
await replayRunEvents([runFrame(realRunId, "failed")]);
|
||||
if ((await notificationCount()) !== 1) throw new Error("a duplicate failed frame repeated the notification");
|
||||
for (const status of ["succeeded", "canceled", "interrupted", "mystery"]) {
|
||||
await replayRunEvents([runFrame(realRunId, status)]);
|
||||
}
|
||||
if ((await notificationCount()) !== 1) {
|
||||
throw new Error(`a non-qualifying status raised a notification: ${JSON.stringify(await notifications())}`);
|
||||
}
|
||||
console.log(` queued -> failed raised one: ${JSON.stringify(failedAlert)}`);
|
||||
|
||||
// running -> waiting raises exactly one decision alert; a duplicate adds none.
|
||||
await replayRunEvents([runFrame(realRunId, "running"), runFrame(realRunId, "waiting")]);
|
||||
if ((await notificationCount()) !== 2) {
|
||||
throw new Error(`running->waiting should notify once: ${JSON.stringify(await notifications())}`);
|
||||
}
|
||||
const waitingAlert = (await notifications())[1];
|
||||
if (
|
||||
waitingAlert.title !== "A run needs your decision" ||
|
||||
waitingAlert.body !== "Smoke run \u00b7 Smoke pipeline" ||
|
||||
waitingAlert.tag !== `${realRunId}:Decision`
|
||||
) {
|
||||
throw new Error(`waiting alert wording/tag: ${JSON.stringify(waitingAlert)}`);
|
||||
}
|
||||
await replayRunEvents([runFrame(realRunId, "waiting")]);
|
||||
if ((await notificationCount()) !== 2) throw new Error("a duplicate waiting frame repeated the notification");
|
||||
|
||||
// First-seen failed/waiting (the subscribe/seed rule) and a dismissed key
|
||||
// raise nothing; the dismissed identity is the one loaded at boot.
|
||||
await replayRunEvents([
|
||||
runFrame(990002, "failed"),
|
||||
runFrame(990003, "waiting"),
|
||||
runFrame(990001, "queued"),
|
||||
runFrame(990001, "failed"),
|
||||
]);
|
||||
if ((await notificationCount()) !== 2) {
|
||||
throw new Error(`pre-existing/dismissed runs notified: ${JSON.stringify(await notifications())}`);
|
||||
}
|
||||
console.log(" running -> waiting raised one; duplicates, terminal/unknown statuses, first-seen and dismissed runs raised none");
|
||||
|
||||
// The click focuses the page and uses the existing Runs navigation to select
|
||||
// the run (L6's URL route is still todo; no route is invented).
|
||||
await page.evaluate(`window.__notificationObjects[0]?.onclick?.()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector('.list.runs .run-row.selected .run-row-meta[data-run-id="${realRunId}"]')`,
|
||||
),
|
||||
{ timeout: 20000, what: "the notification click to open Runs with the run selected" },
|
||||
);
|
||||
console.log(` notification click opened Runs with run ${realRunId} selected`);
|
||||
|
||||
// The denied state is rendered from the same pure wording and offers no control.
|
||||
await page.evaluate(`window.__notificationPermission = "denied"`);
|
||||
await page.clickText("nav.tabs button.tab", "Settings");
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector("#settingsNotificationState")?.textContent === ${JSON.stringify(NOTIFICATION_DENIED)}`),
|
||||
{ timeout: 10000, what: "the denied notification wording" },
|
||||
);
|
||||
const deniedControl = await page.evaluate(`!!document.querySelector("#settingsEnableNotifications")`);
|
||||
if (deniedControl) throw new Error("the denied state still offers the request control");
|
||||
await page.evaluate(`document.querySelector("#settingsNotifications")?.scrollIntoView({ block: "center" })`);
|
||||
await shot("L5-notifications-denied.png");
|
||||
console.log(` notifications denied: "${NOTIFICATION_DENIED}" (no request control)`);
|
||||
console.log(
|
||||
" NOTE: the notification frames above are synthetic and the browser Notification was recorded by a stub; no real OS notification was observed",
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await mkdir(out, { recursive: true });
|
||||
|
||||
@@ -519,7 +763,11 @@ try {
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
}
|
||||
|
||||
if (!scratch) {
|
||||
if (notifyOnly) {
|
||||
await runNotificationChecks();
|
||||
console.log("\nUI SMOKE PASS");
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
} else if (!scratch) {
|
||||
const pipelineCount = await page.evaluate(
|
||||
`document.querySelectorAll("#pipelineRows button.row").length`,
|
||||
);
|
||||
@@ -1482,6 +1730,9 @@ try {
|
||||
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
|
||||
await page.clickText(".detail .detail-tabs .detail-tab", "Graph");
|
||||
await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 });
|
||||
// The run can stop (or be reported `running` with no stage in flight) between
|
||||
// the list read and this graph, so treat the halo as the best effort its
|
||||
// comment promises rather than failing the whole run on a race.
|
||||
const live = await eventually(
|
||||
async () =>
|
||||
page.evaluate(`(() => {
|
||||
@@ -1499,7 +1750,7 @@ try {
|
||||
// detail loaded; this capture is documented as best effort, so say so rather
|
||||
// than fail an unrelated step on live-data timing.
|
||||
if (!live) {
|
||||
console.log(` -- run ${liveRunId} stopped before its active stage rendered; skipped the live halo capture`);
|
||||
console.log(` -- run ${liveRunId} shows no stage in flight; skipped the live graph halo capture`);
|
||||
} else {
|
||||
if (!live.badge) throw new Error(`the active stage showed no elapsed badge: ${JSON.stringify(live)}`);
|
||||
console.log(` live run ${liveRunId}: active stage ${live.activeKey} (pulsing=${live.pulsing}), badge ${live.badge}`);
|
||||
@@ -2414,6 +2665,8 @@ try {
|
||||
meta: row.querySelector(".chat-row-meta")?.textContent ?? "",
|
||||
close: !!row.querySelector(".chat-close"),
|
||||
closed: !!row.querySelector(".chat-closed-chip"),
|
||||
menu: !!row.querySelector(".chat-menu-button"),
|
||||
menuLabel: row.querySelector(".chat-menu-button")?.getAttribute("aria-label") ?? "",
|
||||
})),
|
||||
}))()`);
|
||||
if (chatList.label !== "Search chats") throw new Error(`chat search label: ${chatList.label}`);
|
||||
@@ -2421,13 +2674,15 @@ try {
|
||||
if (chatList.rows.length === 0) throw new Error("no chat sessions rendered");
|
||||
const operatorRow =
|
||||
chatList.rows.find((row) => row.id === expectedSession) ??
|
||||
chatList.rows.find((row) => !row.closed && row.close);
|
||||
chatList.rows.find((row) => !row.closed && row.menu);
|
||||
if (!operatorRow) throw new Error("no open chat row rendered");
|
||||
if (!operatorRow.title) throw new Error("the operator chat row has no title");
|
||||
if (!operatorRow.chips.includes("Operator")) {
|
||||
throw new Error(`chat kind chip: ${operatorRow.chips.join(", ")}`);
|
||||
}
|
||||
if (!operatorRow.close) throw new Error("the open chat row offers no Close chat action");
|
||||
if (!operatorRow.menu || operatorRow.menuLabel !== "Chat actions") {
|
||||
throw new Error(`the open chat row's Chat actions menu: ${JSON.stringify(operatorRow)}`);
|
||||
}
|
||||
console.log(
|
||||
` chat list: ${chatList.rows.length} session(s); "${operatorRow.title}" ` +
|
||||
`[${operatorRow.chips.join(", ")}] — ${operatorRow.meta}`,
|
||||
@@ -2435,9 +2690,11 @@ try {
|
||||
await shot("44-chat-sessions.png");
|
||||
|
||||
// The row's own Close chat… action with NO conversation open: the list offers
|
||||
// it on every open row, so the confirm must still appear. Shown and dismissed
|
||||
// with Cancel; no chat_close is ever sent for the operator's live session.
|
||||
await page.click(`#chatRows .chat-row[data-session="${operatorRow.id}"] .chat-close`);
|
||||
// it on every open row (behind the Chat actions menu), so the confirm must
|
||||
// still appear. Shown and dismissed with Cancel; no chat_close is ever sent for
|
||||
// the operator's live session.
|
||||
await openChatRowMenu(operatorRow.id);
|
||||
await page.click(`#chatRows .chat-row[data-session="${operatorRow.id}"] .chat-menu-close`);
|
||||
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
||||
const listClose = await page.evaluate(
|
||||
`document.querySelector(".confirm-chat-close .confirm-message")?.textContent ?? ""`,
|
||||
@@ -2603,9 +2860,11 @@ try {
|
||||
);
|
||||
await shot("76-chat-created-list.png");
|
||||
|
||||
// Close the one real session it created (chat_close through the C3 confirm) and
|
||||
// capture the Closed chip. Nothing is deleted; the row stays as closed history.
|
||||
await page.click(`#chatRows .chat-row[data-session="${createdId}"] .chat-close`);
|
||||
// Close the one real session it created (chat_close through the C3 confirm,
|
||||
// behind C13's Chat actions menu) and capture the Closed chip. Nothing is
|
||||
// deleted; the row stays as closed history.
|
||||
await openChatRowMenu(createdId);
|
||||
await page.click(`#chatRows .chat-row[data-session="${createdId}"] .chat-menu-close`);
|
||||
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
||||
await page.click(".confirm-chat-close .confirm-accept");
|
||||
await eventually(
|
||||
@@ -2620,13 +2879,15 @@ try {
|
||||
row?.scrollIntoView({ block: "center" });
|
||||
return {
|
||||
closed: !!row?.querySelector(".chat-closed-chip"),
|
||||
hasClose: !!row?.querySelector(".chat-close"),
|
||||
hasReopen: !!row?.querySelector(".chat-reopen"),
|
||||
hasClose: !!row?.querySelector(".chat-menu-close"),
|
||||
hasReopen: !!row?.querySelector(".chat-menu-reopen"),
|
||||
};
|
||||
})()`);
|
||||
if (!createdClosed.closed || createdClosed.hasClose || !createdClosed.hasReopen) {
|
||||
throw new Error(`C2 closed row: ${JSON.stringify(createdClosed)}`);
|
||||
}
|
||||
// Close the actions menu so the capture shows the row itself, not the panel.
|
||||
await page.click(`#chatRows .chat-row[data-session="${createdId}"] .chat-menu-button`);
|
||||
console.log(
|
||||
` C2: created real session ${createdId} ("New chat" in ~) and closed it via chat_close; ` +
|
||||
"it now shows the Closed chip (kept as history, not deleted)",
|
||||
@@ -2644,6 +2905,12 @@ try {
|
||||
const candidates = [
|
||||
...new Set([...(preferred ? [preferred.id] : []), ...openRows, ...chatList.rows.map((r) => r.id)]),
|
||||
];
|
||||
// Record the frames the page sends from before the first genuine open. With
|
||||
// more than one row the test switches away and re-opens, so the assertion below
|
||||
// sees that fresh open; with a server that lists only one session the first
|
||||
// click is itself the fresh open (clicking it again would early-return), and
|
||||
// clearing here would throw that real request away.
|
||||
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
|
||||
let openedId = null;
|
||||
for (const candidate of candidates) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${candidate}"]`);
|
||||
@@ -2664,15 +2931,17 @@ try {
|
||||
}
|
||||
// Leave the discovered session first: the loop above already opened it, and
|
||||
// openChatSession keeps a loaded thread, so clicking it again would early-return
|
||||
// and send nothing. Opening a different row restores a genuine fresh open.
|
||||
// and send nothing. Opening a different row restores a genuine fresh open. With
|
||||
// only one listed session there is no other row, so the loop's own open above is
|
||||
// the fresh-open proof.
|
||||
const otherRow = candidates.find((id) => id !== openedId);
|
||||
if (otherRow) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${otherRow}"]`);
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
|
||||
} else {
|
||||
console.log(" -- the server lists one session, so the first open above is the fresh-open proof");
|
||||
}
|
||||
// Record the frames the page sends, so the C11 chat_shells fetch on open is
|
||||
// asserted rather than assumed.
|
||||
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
|
||||
await page.click(`#chatRows .chat-row[data-session="${openedId}"]`);
|
||||
await page.waitForSelector("#chatTranscript", { timeout: 25000 });
|
||||
await eventually(
|
||||
@@ -3146,7 +3415,8 @@ try {
|
||||
if (!beforeDialog || beforeDialog.top == null || beforeDialog.top === 0) {
|
||||
throw new Error(`the transcript was not mid-scroll before the dialog: ${JSON.stringify(beforeDialog)}`);
|
||||
}
|
||||
await page.click(`#chatRows .chat-row[data-session="${openedId}"] .chat-close`);
|
||||
await openChatRowMenu(openedId);
|
||||
await page.click(`#chatRows .chat-row[data-session="${openedId}"] .chat-menu-close`);
|
||||
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
||||
const closeDialog = await page.evaluate(`(() => ({
|
||||
title: document.querySelector(".confirm-chat-close .confirm-title")?.textContent ?? "",
|
||||
@@ -3565,10 +3835,11 @@ try {
|
||||
|
||||
// (e) `/new` creates a fresh throwaway session (C2's chat_create, sent directly
|
||||
// until C2 lands) and opens it. The operator's session is left untouched. The
|
||||
// throwaway is created EPHEMERAL: this check drives the real page, so without it
|
||||
// every run would leave a permanent "New chat" in the operator's chat list (the
|
||||
// server writes no operator-registry row for an ephemeral create).
|
||||
await page.evaluate(`window.__pipelinesEphemeralChat = true`);
|
||||
// throwaway must stay a listed server session: C12's notice check switches away
|
||||
// to another row and back to it, and C13 reads its row for the device-local
|
||||
// rename; an ephemeral create (2fe6301's `__pipelinesEphemeralChat`) is hidden
|
||||
// from `chat_sessions`, so it is deliberately NOT used here. The session is
|
||||
// closed again in cleanup, like the New-marker throwaway C13 creates itself.
|
||||
await page.fill("#chatInput", "/new");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
@@ -3785,15 +4056,31 @@ try {
|
||||
),
|
||||
{ timeout: 15000, what: "the throwaway session to show as closed" },
|
||||
);
|
||||
await openChatRowMenu(throwawayId);
|
||||
const closedRow = await page.evaluate(`(() => {
|
||||
const row = document.querySelector('.chat-row[data-session="${throwawayId}"]');
|
||||
row?.scrollIntoView({ block: "center" });
|
||||
return {
|
||||
closed: !!row?.querySelector(".chat-closed-chip"),
|
||||
hasClose: !!row?.querySelector(".chat-close"),
|
||||
hasReopen: !!row?.querySelector(".chat-reopen"),
|
||||
items: [...row.querySelectorAll(".chat-menu-panel .chat-menu-item")].map((b) => b.textContent),
|
||||
hasClose: !!row?.querySelector(".chat-menu-close"),
|
||||
hasReopen: !!row?.querySelector(".chat-menu-reopen"),
|
||||
};
|
||||
})()`);
|
||||
if (!closedRow.closed || !closedRow.hasReopen || closedRow.hasClose) {
|
||||
throw new Error(`the closed row's Chat actions menu: ${JSON.stringify(closedRow)}`);
|
||||
}
|
||||
if (closedRow.items.join("|") !== "Rename…|Reopen|Hide on this device") {
|
||||
throw new Error(`the closed row's menu items and order: ${JSON.stringify(closedRow.items)}`);
|
||||
}
|
||||
// Close the menu again (a second press on its own button toggles it shut).
|
||||
await page.evaluate(
|
||||
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-menu-button')?.click()`,
|
||||
);
|
||||
await eventually(
|
||||
() => page.evaluate(`!document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-menu-panel')`),
|
||||
{ timeout: 5000, what: "the closed row's menu to close" },
|
||||
);
|
||||
// Closing finishes the session: the conversation leaves the pane (back to the
|
||||
// list with the select hint) and no row stays selected, as Android's
|
||||
// finishSession does.
|
||||
@@ -4844,6 +5131,8 @@ try {
|
||||
}
|
||||
console.log(` reload restored url=${restoredUrl} workspace=${restoredWorkspace}`);
|
||||
|
||||
await runNotificationChecks();
|
||||
|
||||
// C11: the background-tasks bar. The live server has no running shell to read
|
||||
// safely, so the bar is driven from synthetic `shell` frames replayed through
|
||||
// the page's own socket handler (the same shim) and the bounded output pages are
|
||||
@@ -5181,6 +5470,284 @@ try {
|
||||
);
|
||||
console.log(" chat_shells re-fetched after the stream reconnect (real request)");
|
||||
|
||||
// C13: this device's own chat changes — a local rename that wins over the
|
||||
// server's title, the hide + Undo report, and the seen/New marker. Every
|
||||
// action here is device-local (localStorage): nothing is sent to the server for
|
||||
// a rename or a hide, and the closed throwaway session from C8 is the row used
|
||||
// for the rename/hide captures so the operator's live session is never hidden
|
||||
// in a way the run leaves behind (Hide is undone before the marker step).
|
||||
step("C13: local rename/hide, the hide snackbar and the seen/New marker");
|
||||
await ensureConnected();
|
||||
await page.evaluate(`(() => {
|
||||
const tab = [...document.querySelectorAll("nav.tabs button.tab")].find((b) => b.textContent.trim() === "Chat");
|
||||
if (tab) tab.click();
|
||||
return !!tab;
|
||||
})()`);
|
||||
await page.waitForSelector("#chatRows .chat-row", { timeout: 25000 });
|
||||
|
||||
// (a) Rename… opens the dialog: its exact title, the field label, the pre-fill
|
||||
// and the helper, and Save disabled while the trimmed value is blank.
|
||||
await openChatRowMenu(throwawayId);
|
||||
await page.click(`#chatRows .chat-row[data-session="${throwawayId}"] .chat-menu-rename`);
|
||||
await page.waitForSelector(".confirm-chat-rename", { timeout: 10000 });
|
||||
await page.waitForSelector("#chatRenameInput", { timeout: 5000 });
|
||||
const renameDialog = await page.evaluate(`(() => ({
|
||||
title: document.querySelector(".confirm-chat-rename .confirm-title")?.textContent ?? "",
|
||||
label: document.querySelector(".confirm-chat-rename .chat-rename-label")?.textContent ?? "",
|
||||
value: document.querySelector("#chatRenameInput")?.value ?? null,
|
||||
helper: document.querySelector(".confirm-chat-rename .chat-rename-helper")?.textContent ?? "",
|
||||
save: document.querySelector(".chat-rename-save")?.textContent ?? "",
|
||||
cancel: document.querySelector(".chat-rename-cancel")?.textContent ?? "",
|
||||
}))()`);
|
||||
if (renameDialog.title !== "Rename chat") throw new Error(`rename title: ${renameDialog.title}`);
|
||||
if (renameDialog.label !== "Name") throw new Error(`rename field label: ${renameDialog.label}`);
|
||||
if (renameDialog.value !== "New chat") throw new Error(`rename pre-fill: ${JSON.stringify(renameDialog.value)}`);
|
||||
if (
|
||||
renameDialog.helper !==
|
||||
"The server has no rename for a chat, so this name is kept on this device."
|
||||
) {
|
||||
throw new Error(`rename helper: ${renameDialog.helper}`);
|
||||
}
|
||||
if (renameDialog.save !== "Save" || renameDialog.cancel !== "Cancel") {
|
||||
throw new Error(`rename buttons: ${JSON.stringify(renameDialog)}`);
|
||||
}
|
||||
// Typing toggles Save in place: blank (whitespace) disables it, a real value
|
||||
// enables it, with no re-render of the transcript underneath.
|
||||
await page.fill("#chatRenameInput", " ");
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".chat-rename-save")?.disabled === true`),
|
||||
{ timeout: 5000, what: "Save to disable while the name is blank" },
|
||||
);
|
||||
console.log(` rename dialog: "${renameDialog.title}" / "${renameDialog.label}" pre-filled "${renameDialog.value}"; Save disabled while blank`);
|
||||
await shot("72-chat-rename-dialog.png");
|
||||
|
||||
// (b) Save a locally-titled name; the row shows it now and after a server list
|
||||
// refresh, and the overrides JSON is in localStorage under its own key.
|
||||
await page.fill("#chatRenameInput", "Local capture chat");
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".chat-rename-save")?.disabled === false`),
|
||||
{ timeout: 5000, what: "Save to enable for a non-blank name" },
|
||||
);
|
||||
await page.click(".chat-rename-save");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-rename")`), {
|
||||
timeout: 5000,
|
||||
what: "the rename dialog to close on Save",
|
||||
});
|
||||
const renamedTitle = await eventually(
|
||||
async () => {
|
||||
const value = await page.evaluate(
|
||||
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-row-title')?.textContent ?? ""`,
|
||||
);
|
||||
return value === "Local capture chat" ? value : false;
|
||||
},
|
||||
{ timeout: 8000, what: "the renamed row to show its local title" },
|
||||
);
|
||||
console.log(` row ${throwawayId} shows the local title "${renamedTitle}"`);
|
||||
// Refresh the list from the server (the same header Refresh the page offers);
|
||||
// the local title must still win over the server's own.
|
||||
await page.clickText("nav.tabs button.ghost", "Refresh");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-row-title')?.textContent === "Local capture chat"`,
|
||||
),
|
||||
{ timeout: 15000, what: "the local title to survive a server list refresh" },
|
||||
);
|
||||
const storedOverrides = await page.evaluate(`localStorage.getItem("pipelines.web.chatOverrides.v1")`);
|
||||
const overridesJson = JSON.parse(storedOverrides ?? "{}");
|
||||
if (overridesJson.titles?.[throwawayId] !== "Local capture chat") {
|
||||
throw new Error(`the local title was not persisted: ${storedOverrides}`);
|
||||
}
|
||||
console.log(` after a server list refresh the row still reads "${renamedTitle}"; localStorage ${storedOverrides}`);
|
||||
await shot("73-chat-renamed-row.png");
|
||||
|
||||
// The final row's menu must not be clipped by the list's rounded-corner
|
||||
// overflow: assert the Hide item's own centre is the element a real click
|
||||
// would hit (the review measured the panel cut off at the list's bottom edge
|
||||
// on the last rows). The menu is closed again without acting on it.
|
||||
const lastRowId = await page.evaluate(
|
||||
`(() => { const rows = [...document.querySelectorAll("#chatRows .chat-row")]; return rows.at(-1)?.dataset.session ?? ""; })()`,
|
||||
);
|
||||
if (!lastRowId) throw new Error("C13: no last row to test the menu against");
|
||||
await page.evaluate(`document.querySelector('.chat-row[data-session="${lastRowId}"]')?.scrollIntoView({ block: "center" })`);
|
||||
await openChatRowMenu(lastRowId);
|
||||
const lastMenuHit = await page.evaluate(`(() => {
|
||||
const button = document.querySelector('.chat-row[data-session="${lastRowId}"] .chat-menu-hide');
|
||||
if (!button) return { found: false };
|
||||
const rect = button.getBoundingClientRect();
|
||||
const x = rect.left + rect.width / 2;
|
||||
const y = rect.top + rect.height / 2;
|
||||
const hit = document.elementFromPoint(x, y);
|
||||
return {
|
||||
found: true,
|
||||
label: button.textContent,
|
||||
hit: hit === button || button.contains(hit),
|
||||
rect: { top: rect.top, bottom: rect.bottom },
|
||||
viewport: window.innerHeight,
|
||||
listBottom: document.querySelector(".chat-list")?.getBoundingClientRect().bottom ?? null,
|
||||
};
|
||||
})()`);
|
||||
if (!lastMenuHit.found || !lastMenuHit.hit) {
|
||||
throw new Error(`C13: the last row's menu item is not clickable: ${JSON.stringify(lastMenuHit)}`);
|
||||
}
|
||||
console.log(
|
||||
` last row ${lastRowId}: "${lastMenuHit.label}" is hit-testable at its centre (menu bottom ${Math.round(lastMenuHit.rect.bottom)}, viewport ${lastMenuHit.viewport})`,
|
||||
);
|
||||
await page.click(`#chatRows .chat-row[data-session="${lastRowId}"] .chat-menu-button`);
|
||||
await eventually(
|
||||
() => page.evaluate(`!document.querySelector('.chat-row[data-session="${lastRowId}"] .chat-menu-panel')`),
|
||||
{ timeout: 5000, what: "the last row's menu to close again" },
|
||||
);
|
||||
|
||||
// (c) Hide the row the conversation is open on: it disappears, its conversation
|
||||
// closes, and one snackbar carries the exact message and Undo. Undo puts the
|
||||
// row back and leaves the server untouched.
|
||||
const activeBeforeHide = await page.evaluate(
|
||||
`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`,
|
||||
);
|
||||
if (!activeBeforeHide) throw new Error("C13: no conversation was open before the hide");
|
||||
await openChatRowMenu(activeBeforeHide);
|
||||
await page.click(`#chatRows .chat-row[data-session="${activeBeforeHide}"] .chat-menu-hide`);
|
||||
await page.waitForSelector(".chat-snackbar", { timeout: 10000 });
|
||||
const hiddenState = await page.evaluate(`(() => ({
|
||||
row: !!document.querySelector('.chat-row[data-session="${activeBeforeHide}"]'),
|
||||
snackbars: document.querySelectorAll(".chat-snackbar").length,
|
||||
message: document.querySelector(".chat-snackbar-message")?.textContent ?? "",
|
||||
undo: document.querySelector(".chat-snackbar-undo")?.textContent ?? "",
|
||||
hint: document.querySelector(".chat-detail .empty .muted")?.textContent ?? "",
|
||||
composer: !!document.querySelector("#chatComposer"),
|
||||
hidden: JSON.parse(localStorage.getItem("pipelines.web.chatOverrides.v1") ?? "{}").hidden ?? [],
|
||||
}))()`);
|
||||
if (hiddenState.row) throw new Error(`C13: the hidden row is still listed: ${JSON.stringify(hiddenState)}`);
|
||||
if (hiddenState.snackbars !== 1) throw new Error(`C13: expected one snackbar, got ${hiddenState.snackbars}`);
|
||||
if (hiddenState.message !== "Hidden on this device; the chat stays on the server.") {
|
||||
throw new Error(`C13: snackbar message ${JSON.stringify(hiddenState.message)}`);
|
||||
}
|
||||
if (hiddenState.undo !== "Undo") throw new Error(`C13: snackbar action ${JSON.stringify(hiddenState.undo)}`);
|
||||
if (hiddenState.composer || hiddenState.hint !== "Select a chat to open it.") {
|
||||
throw new Error(`C13: hiding the open conversation did not close it: ${JSON.stringify(hiddenState)}`);
|
||||
}
|
||||
if (!hiddenState.hidden.includes(activeBeforeHide)) {
|
||||
throw new Error(`C13: the hidden id was not persisted: ${JSON.stringify(hiddenState.hidden)}`);
|
||||
}
|
||||
console.log(
|
||||
` hid ${activeBeforeHide}: row gone, conversation closed, one snackbar "${hiddenState.message}" with "${hiddenState.undo}"`,
|
||||
);
|
||||
await shot("74-chat-hide-snackbar.png");
|
||||
|
||||
// Undo restores the row (and only here: the conversation stays closed, exactly
|
||||
// as Android's undoRemove does) and clears the hidden list.
|
||||
await page.click(".chat-snackbar-undo");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector('.chat-row[data-session="${activeBeforeHide}"]') && !document.querySelector(".chat-snackbar")`,
|
||||
),
|
||||
{ timeout: 8000, what: "Undo to restore the hidden row and clear the snackbar" },
|
||||
);
|
||||
const afterUndo = await page.evaluate(
|
||||
`JSON.parse(localStorage.getItem("pipelines.web.chatOverrides.v1") ?? "{}").hidden ?? []`,
|
||||
);
|
||||
if (afterUndo.includes(activeBeforeHide)) {
|
||||
throw new Error(`C13: Undo left the id hidden: ${JSON.stringify(afterUndo)}`);
|
||||
}
|
||||
console.log(` Undo restored ${activeBeforeHide}; hidden ids now ${JSON.stringify(afterUndo)}`);
|
||||
|
||||
// (d) The "New" marker, honestly: the restart rule. A fresh throwaway is
|
||||
// prompted and stopped, and the page is then reloaded — its threads are empty
|
||||
// while the persisted watermark predates the turn, so the non-active row reads
|
||||
// New after the reconnect. First reopen the operator conversation so `/new`
|
||||
// has a directory.
|
||||
await page.evaluate(`document.querySelector('.chat-row[data-session="${sessionId}"]')?.click()`);
|
||||
await page.waitForSelector("#chatTranscript", { timeout: 20000 });
|
||||
await page.fill("#chatInput", "/new");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
const newMarkerId = await eventually(
|
||||
async () => {
|
||||
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`);
|
||||
return id && id !== sessionId && id !== throwawayId ? id : false;
|
||||
},
|
||||
{ timeout: 25000, what: "the fresh throwaway session to open for the New-marker step" },
|
||||
);
|
||||
await page.waitForSelector("#chatInput", { timeout: 10000 });
|
||||
// The watermark for this session is seeded at its creation recency; a real
|
||||
// prompt then advances the server's updated_at past it.
|
||||
await page.fill("#chatInput", "Reply with exactly one word: hi");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
await page.waitForSelector("#chatStop", { timeout: 20000 });
|
||||
await page.click("#chatStop");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`[...document.querySelectorAll(".chat-command-notice-text")].some((n) => n.textContent === "Stopping the running turn…")`,
|
||||
),
|
||||
{ timeout: 15000, what: "the New-marker throwaway turn to be interrupted" },
|
||||
);
|
||||
const watermarkBefore = await page.evaluate(
|
||||
`JSON.parse(localStorage.getItem("pipelines.web.chatSeen.v1") ?? "{}").seenAt?.[${JSON.stringify(newMarkerId)}] ?? 0`,
|
||||
);
|
||||
// A reload empties the page's threads and re-reads the server list: the row is
|
||||
// no longer active, and its server recency has moved past the stored watermark.
|
||||
await page.evaluate(`location.reload()`);
|
||||
await page.waitForSelector("#url", { timeout: 15000 });
|
||||
// A reload starts idle: open the configured endpoint through the header's own
|
||||
// control (the same connect-only path the Settings destination uses).
|
||||
await page.evaluate(`(() => {
|
||||
const control = document.querySelector("#reconnectBtn") || document.querySelector("#connectBtn");
|
||||
if (control) control.click();
|
||||
return !!control;
|
||||
})()`);
|
||||
await ensureConnected(30000);
|
||||
await page.clickText("nav.tabs button.tab", "Chat");
|
||||
await page.waitForSelector("#chatRows .chat-row", { timeout: 25000 });
|
||||
const newMarker = await eventually(
|
||||
async () => {
|
||||
const value = await page.evaluate(`(() => {
|
||||
const row = document.querySelector('.chat-row[data-session="${newMarkerId}"]');
|
||||
const word = row?.querySelector(".chat-activity-new .chat-activity-word")?.textContent ?? "";
|
||||
return { word, selected: !!row?.classList.contains("selected") };
|
||||
})()`);
|
||||
return value.word === "New" ? value : false;
|
||||
},
|
||||
{ timeout: 15000, what: "the non-active row to carry the New marker after the reload" },
|
||||
);
|
||||
const watermarkAfter = await page.evaluate(
|
||||
`JSON.parse(localStorage.getItem("pipelines.web.chatSeen.v1") ?? "{}").seenAt?.[${JSON.stringify(newMarkerId)}] ?? 0`,
|
||||
);
|
||||
console.log(
|
||||
` after the reload, non-active ${newMarkerId} carries the New marker ` +
|
||||
`(watermark before the turn ${watermarkBefore}, after the reload ${watermarkAfter})`,
|
||||
);
|
||||
await shot("75-chat-new-marker.png");
|
||||
|
||||
// Cleanup: open the New-marker throwaway and /close it, so the run leaves no
|
||||
// open session of its own (the rename override on the earlier throwaway is
|
||||
// device-local and the browser profile is temporary).
|
||||
await page.evaluate(`document.querySelector('.chat-row[data-session="${newMarkerId}"]')?.click()`);
|
||||
await page.waitForSelector("#chatInput", { timeout: 20000 });
|
||||
await page.fill("#chatInput", "/close");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
||||
await page.click(".confirm-chat-close .confirm-accept");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
||||
timeout: 15000,
|
||||
what: "the New-marker throwaway to close",
|
||||
});
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector('.chat-row[data-session="${newMarkerId}"] .chat-closed-chip')`,
|
||||
),
|
||||
{ timeout: 15000, what: "the New-marker throwaway to show as closed" },
|
||||
);
|
||||
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
|
||||
|
||||
console.log("\nUI SMOKE PASS");
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user