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:
+39
-10
@@ -230,6 +230,7 @@ import {
|
||||
BACKGROUND_TASKS_TITLE,
|
||||
CHAT_ACTIONS_LABEL,
|
||||
CHAT_ATTACH_LABEL,
|
||||
CHAT_COMMAND_DISMISS_LABEL,
|
||||
CHAT_COMMAND_GLYPH,
|
||||
CHAT_COMPOSER_PLACEHOLDER,
|
||||
CHAT_EMPTY,
|
||||
@@ -283,6 +284,7 @@ import {
|
||||
applyChatEvent,
|
||||
applyChatOverrides,
|
||||
applyChatPermission,
|
||||
appendChatNotice,
|
||||
approvalCard,
|
||||
attachmentDisplayName,
|
||||
attachmentError,
|
||||
@@ -296,6 +298,7 @@ import {
|
||||
chatFollowsAt,
|
||||
chatHeaderMeta,
|
||||
chatNoMatchMessage,
|
||||
chatNoticeLabel,
|
||||
chatOpensAtNewest,
|
||||
chatShowJumpToLatest,
|
||||
chatStreamState,
|
||||
@@ -307,6 +310,7 @@ import {
|
||||
decodeChatOverrides,
|
||||
decodeChatSeen,
|
||||
directoryLabel,
|
||||
dismissChatNotice as dismissChatNoticeModel,
|
||||
emptyChatOverrides,
|
||||
emptyChatSeen,
|
||||
encodeChatOverrides,
|
||||
@@ -316,6 +320,7 @@ import {
|
||||
hideChatOverride,
|
||||
historyResync,
|
||||
isChatSessionUnseen,
|
||||
makeChatNotice,
|
||||
markChatUnseen,
|
||||
mergeHistoryPage,
|
||||
mergeShellFrame,
|
||||
@@ -342,6 +347,7 @@ import {
|
||||
shellCommandSummary,
|
||||
shellOutputState,
|
||||
shellsLoaded,
|
||||
takeChatNoticeOffer as takeChatNoticeOfferModel,
|
||||
formatToolDuration,
|
||||
threadElapsedMillis,
|
||||
threadPhase,
|
||||
@@ -4654,15 +4660,15 @@ function addChatNotice(sessionId, text, { failed = false, offer = null } = {}) {
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
if (!thread) return;
|
||||
chatNoticeSeq += 1;
|
||||
const notice = { id: `notice-${chatNoticeSeq}`, text, failed, offer };
|
||||
setThread(sessionId, { notices: [...(thread.notices ?? []), notice] });
|
||||
const notice = makeChatNotice(`notice-${chatNoticeSeq}`, text, { failed, offer });
|
||||
setThread(sessionId, { notices: appendChatNotice(thread.notices, notice) });
|
||||
}
|
||||
|
||||
/** Remove one local command line (the operator cancelled its offer). */
|
||||
/** Remove one local command line (the operator cancelled or dismissed it). */
|
||||
function dismissChatNotice(sessionId, noticeId) {
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
if (!thread) return;
|
||||
setThread(sessionId, { notices: (thread.notices ?? []).filter((n) => n.id !== noticeId) });
|
||||
setThread(sessionId, { notices: dismissChatNoticeModel(thread.notices, noticeId) });
|
||||
renderContent();
|
||||
}
|
||||
|
||||
@@ -4672,10 +4678,11 @@ function dismissChatNotice(sessionId, noticeId) {
|
||||
*/
|
||||
function takeChatNoticeOffer(sessionId, noticeId) {
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
const notice = (thread?.notices ?? []).find((n) => n.id === noticeId);
|
||||
if (!notice || notice.offer == null) return null;
|
||||
setThread(sessionId, { notices: (thread.notices ?? []).filter((n) => n.id !== noticeId) });
|
||||
return notice.offer;
|
||||
if (!thread) return null;
|
||||
const taken = takeChatNoticeOfferModel(thread.notices, noticeId);
|
||||
if (taken.offer == null) return null;
|
||||
setThread(sessionId, { notices: taken.notices });
|
||||
return taken.offer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4822,7 +4829,12 @@ function applyChatCommandEffect(sessionId, session, effect) {
|
||||
async function startChatSession(directory) {
|
||||
const from = state.chatActiveId;
|
||||
try {
|
||||
const created = await repo.chatCreate("New chat", directory);
|
||||
// An automated check (the UI smoke) can mark its throwaway chat ephemeral, so
|
||||
// creating one for verification never adds a stray "New chat" to the
|
||||
// operator's list. Set only by test tooling; a normal page leaves it unset.
|
||||
const created = await repo.chatCreate("New chat", directory, undefined, {
|
||||
ephemeral: globalThis.__pipelinesEphemeralChat === true,
|
||||
});
|
||||
// The list is the server's; insert the created session so the row is present
|
||||
// before the conversation opens, then refresh from the server.
|
||||
state.chatSessions = [created, ...state.chatSessions.filter((s) => s.id !== created.id)];
|
||||
@@ -6151,6 +6163,7 @@ function renderChatCommandNotice(sessionId, notice) {
|
||||
const row = h("div", {
|
||||
class: `chat-command-notice${failed ? " chat-command-notice-failed" : ""}`,
|
||||
role: "note",
|
||||
"data-notice-id": notice?.id ?? "",
|
||||
});
|
||||
const head = h("div", { class: "chat-command-notice-head" });
|
||||
head.append(
|
||||
@@ -6163,7 +6176,7 @@ function renderChatCommandNotice(sessionId, notice) {
|
||||
}),
|
||||
);
|
||||
head.append(
|
||||
h("span", { class: "chat-command-notice-label", text: failed ? "Command failed" : "Command" }),
|
||||
h("span", { class: "chat-command-notice-label", text: chatNoticeLabel(failed) }),
|
||||
);
|
||||
row.append(head);
|
||||
row.append(h("div", { class: "chat-command-notice-text", text: notice?.text ?? "" }));
|
||||
@@ -6186,6 +6199,22 @@ function renderChatCommandNotice(sessionId, notice) {
|
||||
}),
|
||||
);
|
||||
row.append(actions);
|
||||
} else {
|
||||
// Android only offers the Send/Cancel pair on an offer-bearing notice, so a
|
||||
// `/help` or `/new` line cannot be dismissed there. The browser item requires
|
||||
// each notice to be individually dismissible; the wording and the offer pair
|
||||
// still match the app verbatim, and this extra control is stated in PARITY.
|
||||
const actions = h("div", { class: "chat-command-notice-actions" });
|
||||
actions.append(
|
||||
h("button", {
|
||||
class: "ghost chat-command-dismiss",
|
||||
type: "button",
|
||||
text: "Dismiss",
|
||||
"aria-label": CHAT_COMMAND_DISMISS_LABEL,
|
||||
onclick: () => dismissChatNotice(sessionId, notice.id),
|
||||
}),
|
||||
);
|
||||
row.append(actions);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
+59
-1
@@ -20,7 +20,11 @@
|
||||
// chatShowJumpToLatest, chatOpensAtNewest,
|
||||
// chatFirstScroll
|
||||
// ui/chat/ChatStore.kt the history page merge (dedupe by id, prepend an
|
||||
// older page, replace nextCursor/hasMore)
|
||||
// older page, replace nextCursor/hasMore) and the
|
||||
// local command notices (append, dismiss one,
|
||||
// take an offer; ChatCommandNotice)
|
||||
// ui/chat/ChatCommandUi.kt the Command / Command failed labels and the
|
||||
// terminal glyph of one local notice line
|
||||
// ui/chat/ChatComposer.kt composerAction, composerCanSend/composerSendEnabled,
|
||||
// the submit routing (command vs prompt)
|
||||
// ui/chat/ChatCommands.kt CHAT_COMMANDS, parseChatInput, chatCommandSuggestions,
|
||||
@@ -1624,6 +1628,60 @@ export const CHAT_QUEUED_NOTICE = "Queued — it will send when the current turn
|
||||
*/
|
||||
export const CHAT_COMMAND_GLYPH = ">_";
|
||||
|
||||
/** The two labels a local command line can carry (ChatCommandUi.kt). */
|
||||
export const CHAT_COMMAND_LABEL = "Command";
|
||||
export const CHAT_COMMAND_FAILED_LABEL = "Command failed";
|
||||
|
||||
/** The accessible name of an offerless notice's dismiss control. */
|
||||
export const CHAT_COMMAND_DISMISS_LABEL = "Dismiss command notice";
|
||||
|
||||
/**
|
||||
* The label for one command notice: `Command failed` when the command could not
|
||||
* be honoured, else `Command` (ChatCommandUi.kt's own choice). The same flag
|
||||
* selects the error tint on the caller's row.
|
||||
*/
|
||||
export function chatNoticeLabel(failed) {
|
||||
return failed === true ? CHAT_COMMAND_FAILED_LABEL : CHAT_COMMAND_LABEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* One local command line, the app's `ChatCommandNotice` shape: it lives beside a
|
||||
* conversation, never inside its messages, so it is never sent to the agent.
|
||||
* [offer] is set only for an unrecognised command, whose draft the operator can
|
||||
* still choose to send as a message.
|
||||
*/
|
||||
export function makeChatNotice(id, text, { failed = false, offer = null } = {}) {
|
||||
return {
|
||||
id: str(id),
|
||||
text: str(text),
|
||||
failed: failed === true,
|
||||
offer: offer == null ? null : str(offer),
|
||||
};
|
||||
}
|
||||
|
||||
/** Append one notice to a conversation's list, preserving order. */
|
||||
export function appendChatNotice(notices, notice) {
|
||||
return [...(notices ?? []), notice];
|
||||
}
|
||||
|
||||
/** Drop one notice by id, leaving every other notice and its order untouched. */
|
||||
export function dismissChatNotice(notices, noticeId) {
|
||||
return (notices ?? []).filter((notice) => notice?.id !== noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the draft an unrecognised-command notice offers, removing the notice
|
||||
* first (mirrors `ChatStore.takeNoticeOffer`). Returns `{notices, offer}`:
|
||||
* `offer` is null — and the list is returned untouched — when the notice is
|
||||
* missing, already taken or carries no offer, so a stale tap sends nothing.
|
||||
*/
|
||||
export function takeChatNoticeOffer(notices, noticeId) {
|
||||
const list = notices ?? [];
|
||||
const notice = list.find((entry) => entry?.id === noticeId);
|
||||
if (!notice || notice.offer == null) return { notices: list, offer: null };
|
||||
return { notices: dismissChatNotice(list, noticeId), offer: notice.offer };
|
||||
}
|
||||
|
||||
/** The two values of [composerAction]. */
|
||||
export const COMPOSER_SEND = "send";
|
||||
export const COMPOSER_STOP = "stop";
|
||||
|
||||
@@ -389,11 +389,16 @@ export class PipelinesRepository {
|
||||
* never created in whatever directory the server happens to be running in. The
|
||||
* reply's `chat_session` is returned, or a `ProtocolError` when the server did
|
||||
* not return one.
|
||||
*
|
||||
* `ephemeral` creates a verification chat: the server makes and bootstraps the
|
||||
* session but records no operator-registry row, so the chat never appears in
|
||||
* `chat_sessions` for the operator. Automated checks that drive this real page
|
||||
* set it, so a run can never leave a stray "New chat" in the operator's list.
|
||||
*/
|
||||
async chatCreate(title, directory, operationId = newChatOperationId()) {
|
||||
async chatCreate(title, directory, operationId = newChatOperationId(), { ephemeral = false } = {}) {
|
||||
const response = await this.#client.call({
|
||||
type: Protocol.CHAT_CREATE,
|
||||
[ChatKeys.CREATE]: { title, directory, operation_id: operationId },
|
||||
[ChatKeys.CREATE]: { title, directory, operation_id: operationId, ...(ephemeral ? { ephemeral: true } : {}) },
|
||||
});
|
||||
const session = response[ChatKeys.SESSION];
|
||||
if (!session) {
|
||||
|
||||
Reference in New Issue
Block a user