Merge branch 'main' into web-chat-local
Resolve the C11/C12 vs C13 overlap in the chat work:
- PARITY: keep main's done C11/C12 rows and this branch's done C13 row.
- app.js/chat tests: keep both import/helper sets (notices and overrides/seen).
- ui-smoke: keep main's C11 background-task bar, C12 notice checks and the
shared composer throwaway, and C13's row-menu rename/hide/seen checks.
The composer throwaway stays a listed server session: C12 switches away
and back to it and C13 reads its row, which an ephemeral create (2fe6301)
deliberately hides from chat_sessions. The live-run graph halo check is
best effort as its own comment says, so a run with no stage in flight at
capture time skips instead of failing the whole smoke.
This commit is contained in:
@@ -9,7 +9,10 @@ import {
|
||||
BACKGROUND_TASK_VISIBLE_ROWS,
|
||||
CHAT_ACTIONS_LABEL,
|
||||
CHAT_COMMANDS,
|
||||
CHAT_COMMAND_DISMISS_LABEL,
|
||||
CHAT_COMMAND_FAILED_LABEL,
|
||||
CHAT_COMMAND_GLYPH,
|
||||
CHAT_COMMAND_LABEL,
|
||||
CHAT_FOLLOW_THRESHOLD_PX,
|
||||
CHAT_HIDE_ACTION,
|
||||
CHAT_QUEUED_NOTICE,
|
||||
@@ -58,6 +61,7 @@ import {
|
||||
TURN_PHASE_TOOL,
|
||||
TURN_PHASE_WAITING,
|
||||
TURN_THINKING_WINDOW_MILLIS,
|
||||
appendChatNotice,
|
||||
applyChatEvent,
|
||||
applyChatOverrides,
|
||||
applyChatPermission,
|
||||
@@ -77,6 +81,7 @@ import {
|
||||
chatFollowsAt,
|
||||
chatHeaderMeta,
|
||||
chatNoMatchMessage,
|
||||
chatNoticeLabel,
|
||||
chatOpensAtNewest,
|
||||
chatSeenWatermark,
|
||||
chatShowJumpToLatest,
|
||||
@@ -91,6 +96,7 @@ import {
|
||||
decodeChatSeen,
|
||||
deltaPartId,
|
||||
directoryLabel,
|
||||
dismissChatNotice,
|
||||
emptyChatOverrides,
|
||||
emptyChatSeen,
|
||||
encodeChatOverrides,
|
||||
@@ -102,6 +108,7 @@ import {
|
||||
historyResync,
|
||||
isChatSessionUnseen,
|
||||
lineDiff,
|
||||
makeChatNotice,
|
||||
markChatUnseen,
|
||||
mergeHistoryPage,
|
||||
mergeShellFrame,
|
||||
@@ -134,6 +141,7 @@ import {
|
||||
shellCommandSummary,
|
||||
shellOutputState,
|
||||
shellsLoaded,
|
||||
takeChatNoticeOffer,
|
||||
threadElapsedMillis,
|
||||
threadPhase,
|
||||
threadRunningTools,
|
||||
@@ -858,6 +866,103 @@ test("a command notice carries one terminal glyph for both states", () => {
|
||||
assert.equal(CHAT_COMMAND_GLYPH, ">_");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Local command notices (C12) — ChatStore.kt notice/dismissNotice/takeNoticeOffer
|
||||
// and ChatCommandUi.kt's labels
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("chatNoticeLabel names a command and its failure", () => {
|
||||
assert.equal(CHAT_COMMAND_LABEL, "Command");
|
||||
assert.equal(CHAT_COMMAND_FAILED_LABEL, "Command failed");
|
||||
assert.equal(chatNoticeLabel(false), "Command");
|
||||
assert.equal(chatNoticeLabel(true), "Command failed");
|
||||
// Anything that is not the literal failed flag keeps the ordinary label.
|
||||
assert.equal(chatNoticeLabel(undefined), "Command");
|
||||
assert.equal(chatNoticeLabel("failed"), "Command");
|
||||
});
|
||||
|
||||
test("the offerless notice's dismiss control has an accessible name", () => {
|
||||
assert.equal(CHAT_COMMAND_DISMISS_LABEL, "Dismiss command notice");
|
||||
});
|
||||
|
||||
test("makeChatNotice keeps the id, text, failure flag and offer", () => {
|
||||
assert.deepEqual(makeChatNotice("notice-1", "No turn is running in this chat."), {
|
||||
id: "notice-1",
|
||||
text: "No turn is running in this chat.",
|
||||
failed: false,
|
||||
offer: null,
|
||||
});
|
||||
assert.deepEqual(
|
||||
makeChatNotice("notice-2", "Started a new session.", { failed: true, offer: "/nope" }),
|
||||
{ id: "notice-2", text: "Started a new session.", failed: true, offer: "/nope" },
|
||||
);
|
||||
});
|
||||
|
||||
test("appendChatNotice appends one notice and preserves order", () => {
|
||||
const first = makeChatNotice("notice-1", "Command one");
|
||||
const second = makeChatNotice("notice-2", "Command two", { failed: true });
|
||||
const afterFirst = appendChatNotice([], first);
|
||||
const afterSecond = appendChatNotice(afterFirst, second);
|
||||
assert.deepEqual(afterSecond, [first, second]);
|
||||
// The previous list is never mutated.
|
||||
assert.deepEqual(afterFirst, [first]);
|
||||
assert.deepEqual(appendChatNotice(undefined, first), [first]);
|
||||
});
|
||||
|
||||
test("dismissChatNotice removes exactly the named notice", () => {
|
||||
const first = makeChatNotice("notice-1", "Command one");
|
||||
const second = makeChatNotice("notice-2", "Command two", { failed: true });
|
||||
const third = makeChatNotice("notice-3", "Command three");
|
||||
assert.deepEqual(dismissChatNotice([first, second, third], "notice-2"), [first, third]);
|
||||
// An unknown id leaves the list as it was.
|
||||
assert.deepEqual(dismissChatNotice([first, third], "notice-9"), [first, third]);
|
||||
assert.deepEqual(dismissChatNotice(undefined, "notice-1"), []);
|
||||
});
|
||||
|
||||
test("takeChatNoticeOffer removes the notice and returns its draft", () => {
|
||||
const offerless = makeChatNotice("notice-1", "Command one");
|
||||
const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
|
||||
const taken = takeChatNoticeOffer([offerless, offered], "notice-2");
|
||||
assert.equal(taken.offer, "/nope");
|
||||
assert.deepEqual(taken.notices, [offerless]);
|
||||
});
|
||||
|
||||
test("takeChatNoticeOffer returns null and leaves the list for a stale or offerless notice", () => {
|
||||
const offerless = makeChatNotice("notice-1", "Command one");
|
||||
const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
|
||||
for (const id of ["notice-1", "notice-9"]) {
|
||||
const taken = takeChatNoticeOffer([offerless, offered], id);
|
||||
assert.equal(taken.offer, null);
|
||||
assert.deepEqual(taken.notices, [offerless, offered]);
|
||||
}
|
||||
// A second take of an already-taken id is stale and sends nothing.
|
||||
const firstTake = takeChatNoticeOffer([offered], "notice-2");
|
||||
const secondTake = takeChatNoticeOffer(firstTake.notices, "notice-2");
|
||||
assert.equal(secondTake.offer, null);
|
||||
assert.deepEqual(secondTake.notices, []);
|
||||
});
|
||||
|
||||
test("notice lists are scoped per conversation and never share state", () => {
|
||||
// Two conversations' notice lists are independent arrays: appending or
|
||||
// dismissing in one cannot touch the other (the app keeps one per thread).
|
||||
const operator = [];
|
||||
const throwaway = [];
|
||||
const operatorNotice = makeChatNotice("notice-1", "Operator command");
|
||||
const throwawayNotice = makeChatNotice("notice-2", "Throwaway command", { failed: true });
|
||||
const operatorAfter = appendChatNotice(operator, operatorNotice);
|
||||
const throwawayAfter = appendChatNotice(throwaway, throwawayNotice);
|
||||
assert.deepEqual(operatorAfter, [operatorNotice]);
|
||||
assert.deepEqual(throwawayAfter, [throwawayNotice]);
|
||||
assert.deepEqual(dismissChatNotice(operatorAfter, "notice-1"), []);
|
||||
assert.deepEqual(throwawayAfter, [throwawayNotice]);
|
||||
const taken = takeChatNoticeOffer(
|
||||
appendChatNotice(throwawayAfter, makeChatNotice("notice-3", "Offer", { offer: "/help" })),
|
||||
"notice-3",
|
||||
);
|
||||
assert.equal(taken.offer, "/help");
|
||||
assert.deepEqual(operatorAfter, [operatorNotice]);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Slash commands (C9)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user