web: unify detail headers, queue follow-ups, move thinking outside bubbles
Every detail screen now owns one 44px chevron Back control beside its title. Sending appends the user's message immediately and keeps Send available beside Stop so a follow-up can be queued. Reasoning renders above the answer bubble rather than inside it.
This commit is contained in:
+23
-14
@@ -44,7 +44,7 @@ import {
|
||||
SearchSequencer,
|
||||
} from "./search.js";
|
||||
import { DecisionDraft, pendingDecision } from "./actions.js";
|
||||
import { h } from "./dom.js";
|
||||
import { backChevronIcon, h } from "./dom.js";
|
||||
import { createModalController } from "./modal.js";
|
||||
import { describeError, isExecuting } from "./format.js";
|
||||
import {
|
||||
@@ -974,19 +974,17 @@ function listSubtitle(view) {
|
||||
}
|
||||
}
|
||||
|
||||
function backControl(view) {
|
||||
function backButton(view) {
|
||||
return h(
|
||||
"div",
|
||||
{ class: "pane-back" },
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
onclick: () => closeDetail(view),
|
||||
},
|
||||
h("span", { "aria-hidden": "true", text: "\u2190" }),
|
||||
h("span", { text: "Back to list" }),
|
||||
),
|
||||
"button",
|
||||
{
|
||||
class: "ghost back-button",
|
||||
type: "button",
|
||||
"aria-label": "Back to list",
|
||||
title: "Back to list",
|
||||
onclick: () => closeDetail(view),
|
||||
},
|
||||
backChevronIcon(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1076,7 +1074,18 @@ function focusDetailHeading() {
|
||||
|
||||
function detailPaneFor(view, body, { detailOpen, tabs }) {
|
||||
const pane = h("section", { class: "detail-pane", "aria-label": `${view} detail` });
|
||||
if (detailOpen) pane.append(backControl(view));
|
||||
if (detailOpen) {
|
||||
// One header for every detail screen: the same chevron control on the left
|
||||
// and the screen's own h1 beside it, vertically centred. The title leaves the
|
||||
// scroller so it cannot drift away from the control.
|
||||
const header = h("div", { class: "detail-head" }, backButton(view));
|
||||
const title = body.querySelector("#detailTitle");
|
||||
if (title) {
|
||||
title.remove();
|
||||
header.append(title);
|
||||
}
|
||||
pane.append(header);
|
||||
}
|
||||
const scroll = h("div", {
|
||||
id: "detail-panel",
|
||||
class: "pane-scroll",
|
||||
|
||||
+3
-3
@@ -1847,9 +1847,9 @@ export function composerSubmit(thread, selected = 0) {
|
||||
const command = chatCommandForEnter(draft, selected);
|
||||
if (command != null) return { kind: "command", text: command };
|
||||
if (chatDraftIsSlash(draft)) return { kind: "command", text: draft };
|
||||
if (composerAction(thread) === COMPOSER_SEND && composerCanSend(thread)) {
|
||||
return { kind: "send" };
|
||||
}
|
||||
// A running turn accepts a follow-up too: the server queues it behind the
|
||||
// current turn instead of making the operator wait for Send to reappear.
|
||||
if (composerCanSend(thread)) return { kind: "send" };
|
||||
return { kind: "none" };
|
||||
}
|
||||
|
||||
|
||||
@@ -75,3 +75,22 @@ export function kvMono(key, value) {
|
||||
h("span", { class: "kv-val" }, h("code", { text: value })),
|
||||
);
|
||||
}
|
||||
|
||||
/** A 24px chevron-left for the one Back control every detail screen uses. */
|
||||
export function backChevronIcon(className = "back-chevron") {
|
||||
const NS = "http://www.w3.org/2000/svg";
|
||||
const svg = document.createElementNS(NS, "svg");
|
||||
svg.setAttribute("class", className);
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
const path = document.createElementNS(NS, "path");
|
||||
path.setAttribute("d", "M15 5 8 12l7 7");
|
||||
path.setAttribute("fill", "none");
|
||||
path.setAttribute("stroke", "currentColor");
|
||||
path.setAttribute("stroke-width", "2");
|
||||
path.setAttribute("stroke-linecap", "round");
|
||||
path.setAttribute("stroke-linejoin", "round");
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
|
||||
+57
-29
@@ -3,10 +3,10 @@
|
||||
// slash commands, notices and the local rename/hide/seen store. Pure models live
|
||||
// in chat.js and markdown.js; this module owns the DOM and the chat wire wiring.
|
||||
|
||||
import { h } from "../dom.js";
|
||||
import { backChevronIcon, h } from "../dom.js";
|
||||
import { readChatStars, writeChatStars } from "../chatStars.js";
|
||||
import { describeError } from "../format.js";
|
||||
import { SHELL_OUTPUT_LIMIT, newChatOperationId } from "../repository.js";
|
||||
import { SHELL_OUTPUT_LIMIT, nativeChatMessageId, newChatOperationId } from "../repository.js";
|
||||
import { codeBlockLabel, parseInline, parseMarkdown } from "../markdown.js";
|
||||
import { highlight } from "../highlight.js";
|
||||
import { formatDuration } from "../runs.js";
|
||||
@@ -1566,11 +1566,31 @@ async function sendChatPrompt(sessionId, session) {
|
||||
const text = String(thread.draft).trim();
|
||||
if (text === "") return;
|
||||
const attachments = thread.attachments ?? [];
|
||||
const operationId = newChatOperationId();
|
||||
const messageId = nativeChatMessageId(operationId);
|
||||
// Show the operator's own turn at once, with the id OpenCode will persist.
|
||||
// Waiting for the first assistant frame made the running placeholder appear
|
||||
// before the message the operator just sent.
|
||||
const optimistic = {
|
||||
id: messageId || `local-${operationId}`,
|
||||
session_id: sessionId,
|
||||
role: "user",
|
||||
operation_id: operationId,
|
||||
parts: [{ type: "text", text }],
|
||||
};
|
||||
releaseAttachments(attachments);
|
||||
setThread(sessionId, { draft: "", attachments: [] });
|
||||
setThread(sessionId, {
|
||||
draft: "",
|
||||
attachments: [],
|
||||
running: true,
|
||||
messages: [...(thread.messages ?? []), optimistic],
|
||||
});
|
||||
saveChatDraft(sessionId, "");
|
||||
renderContent();
|
||||
await postChatPrompt(sessionId, text, attachments);
|
||||
await postChatPrompt(sessionId, text, attachments, {
|
||||
operationId,
|
||||
optimisticId: optimistic.id,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1579,13 +1599,13 @@ async function sendChatPrompt(sessionId, session) {
|
||||
* server's reason if it is rejected. The live transcript item (C5) owns the
|
||||
* optimistic bubble; this only drives the composer and its request.
|
||||
*/
|
||||
async function postChatPrompt(sessionId, text, attachments) {
|
||||
async function postChatPrompt(sessionId, text, attachments, { operationId, optimisticId } = {}) {
|
||||
const body = String(text).trim();
|
||||
if (body === "") return;
|
||||
setThread(sessionId, { running: true });
|
||||
renderContent();
|
||||
try {
|
||||
const queued = await repo.chatPrompt(sessionId, body, attachmentFiles(attachments));
|
||||
const queued = await repo.chatPrompt(sessionId, body, attachmentFiles(attachments), operationId);
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
if (!thread) return;
|
||||
// Prompting a closed session reopens it on the server; clear the local mark
|
||||
@@ -1599,12 +1619,16 @@ async function postChatPrompt(sessionId, text, attachments) {
|
||||
releaseAttachment(attachment);
|
||||
return { ...attachment, thumbUrl: null, error: message };
|
||||
});
|
||||
const current = state.chatThreads.get(sessionId);
|
||||
setThread(sessionId, {
|
||||
running: false,
|
||||
queued: false,
|
||||
error: message,
|
||||
draft: body,
|
||||
attachments: restored,
|
||||
messages: optimisticId
|
||||
? (current?.messages ?? []).filter((entry) => entry.id !== optimisticId)
|
||||
: current?.messages,
|
||||
});
|
||||
saveChatDraft(sessionId, body);
|
||||
state.actionError = message;
|
||||
@@ -1917,13 +1941,13 @@ function renderChatCreate() {
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: "ghost chat-create-back",
|
||||
class: "ghost back-button chat-create-back",
|
||||
type: "button",
|
||||
"aria-label": CHAT_CREATE_BACK_LABEL,
|
||||
title: CHAT_CREATE_BACK_LABEL,
|
||||
onclick: cancelNewChat,
|
||||
},
|
||||
h("span", { class: "chat-create-back-glyph", "aria-hidden": "true", text: "←" }),
|
||||
backChevronIcon(),
|
||||
),
|
||||
// The create pane is a chat detail too: its title is the route's h1.
|
||||
h("h1", {
|
||||
@@ -2142,13 +2166,13 @@ function renderChatConversation() {
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: "ghost chat-create-back chat-back",
|
||||
class: "ghost back-button chat-back",
|
||||
type: "button",
|
||||
"aria-label": "Back to chats",
|
||||
title: "Back to chats",
|
||||
onclick: () => closeDetail("chat"),
|
||||
},
|
||||
h("span", { class: "chat-create-back-glyph", "aria-hidden": "true", text: "←" }),
|
||||
backChevronIcon(),
|
||||
),
|
||||
);
|
||||
const titles = h("div", { class: "chat-bar-titles" });
|
||||
@@ -2814,9 +2838,12 @@ function renderChatAgentTurn(turn, streaming = false, elapsedMillis = () => 0) {
|
||||
const wrap = h("div", { class: "chat-turn chat-turn-agent" });
|
||||
const bubble = h("div", { class: "chat-bubble agent-bubble" });
|
||||
const steps = turn.reasoningSteps;
|
||||
if (steps.length > 0) bubble.append(renderChatReasoning(turn, streaming));
|
||||
// Thinking is evidence about the turn, not part of the answer bubble. Keep it
|
||||
// outside and above the message, the way the tool summary sits outside and
|
||||
// below it.
|
||||
if (steps.length > 0) wrap.append(renderChatReasoning(turn, streaming));
|
||||
if (turn.answer.trim() !== "") bubble.append(renderMarkdown(turn.answer));
|
||||
wrap.append(bubble);
|
||||
if (bubble.childElementCount > 0) wrap.append(bubble);
|
||||
// The tool summary is a quiet line beside the message, not a highlighted chip
|
||||
// inside it; its panel still opens right there.
|
||||
if (turn.tools.length > 0) {
|
||||
@@ -3375,23 +3402,8 @@ function fillCommandPalette(palette, suggestions, selected, onPick) {
|
||||
function fillComposerPrimary(primary, thread, { onSend, onStop } = {}) {
|
||||
if (!primary) return;
|
||||
primary.replaceChildren();
|
||||
if (composerAction(thread) === COMPOSER_STOP) {
|
||||
primary.append(
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: "chat-stop",
|
||||
id: "chatStop",
|
||||
type: "button",
|
||||
"aria-label": CHAT_STOP_LABEL,
|
||||
title: CHAT_STOP_LABEL,
|
||||
onclick: onStop,
|
||||
},
|
||||
"■",
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Send is always available; while a turn runs, Stop sits beside it and a send
|
||||
// is queued behind the current turn instead of making the operator wait.
|
||||
primary.append(
|
||||
h(
|
||||
"button",
|
||||
@@ -3407,6 +3419,22 @@ function fillComposerPrimary(primary, thread, { onSend, onStop } = {}) {
|
||||
"➤",
|
||||
),
|
||||
);
|
||||
if (composerAction(thread) === COMPOSER_STOP) {
|
||||
primary.append(
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: "chat-stop",
|
||||
id: "chatStop",
|
||||
type: "button",
|
||||
"aria-label": CHAT_STOP_LABEL,
|
||||
title: CHAT_STOP_LABEL,
|
||||
onclick: onStop,
|
||||
},
|
||||
"■",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** The removable chips for the files attached to the next message. */
|
||||
|
||||
Reference in New Issue
Block a user