fix(web): move chat metrics into top-bar information panel
This commit is contained in:
@@ -516,6 +516,9 @@ export function createModalController(options = {}) {
|
||||
const wasTop = index === stack.length - 1;
|
||||
stack.splice(index, 1);
|
||||
if (entry.panel?.parentElement) entry.panel.remove();
|
||||
// Lifecycle cleanup also runs for browser Back and programmatic closeAll,
|
||||
// not just the owner's Escape/backdrop request handler.
|
||||
entry.options?.onClosed?.();
|
||||
if (wasTop) {
|
||||
const next = top();
|
||||
if (next) setLowerInert(next, false);
|
||||
|
||||
+50
-2
@@ -755,7 +755,7 @@ function refreshChatTranscript(sessionId) {
|
||||
const bar = document.querySelector(".chat-bar");
|
||||
const jump = bar?.querySelector(".chat-approval-jump");
|
||||
const jumpLabel=chatApprovalCards(thread).some(card=>card.actionable) ? WAITING_FOR_APPROVAL_LABEL : "Answer question";
|
||||
if (awaiting && bar && !jump) bar.append(approvalJumpButton(jumpLabel));
|
||||
if (awaiting && bar && !jump) bar.insertBefore(approvalJumpButton(jumpLabel), bar.querySelector("#chatUsageInfo"));
|
||||
else if (awaiting && jump) jump.textContent=jumpLabel;
|
||||
else if (!awaiting) jump?.remove();
|
||||
captureChatPosition();
|
||||
@@ -2491,8 +2491,46 @@ function refreshChatUsageMetrics(sessionId, thread) {
|
||||
if (metrics?.dataset.session === sessionId) metrics.replaceWith(renderChatUsageMetrics(thread, sessionId));
|
||||
}
|
||||
|
||||
let usageInfoSessionId = null;
|
||||
function openChatUsageInfo(sessionId, trigger) {
|
||||
if (modal.isOpen("chat-usage-info")) {
|
||||
modal.close("chat-usage-info");
|
||||
return;
|
||||
}
|
||||
usageInfoSessionId = sessionId;
|
||||
trigger.setAttribute("aria-expanded", "true");
|
||||
const close = () => modal.close("chat-usage-info");
|
||||
const overlay = h("div", {
|
||||
class: "chat-usage-info-overlay",
|
||||
id: "chatUsageInfoPanel",
|
||||
role: "dialog",
|
||||
"aria-modal": "true",
|
||||
"aria-label": "Chat information",
|
||||
});
|
||||
const panel = h("div", { class: "chat-usage-info-panel" });
|
||||
panel.style.setProperty("--chat-info-top", `${trigger.getBoundingClientRect().bottom + 8}px`);
|
||||
panel.append(h("div", { class: "chat-usage-info-heading" },
|
||||
h("h2", { text: "Chat information" }),
|
||||
h("button", { class: "ghost chat-usage-info-close", type: "button", text: "Close", onclick: close }),
|
||||
));
|
||||
panel.append(renderChatUsageMetrics(state.chatThreads.get(sessionId), sessionId));
|
||||
panel.append(h("p", { class: "muted chat-usage-info-note", text: "Last reported by the harness. Unavailable values are not estimated." }));
|
||||
overlay.append(panel);
|
||||
overlay.addEventListener("click", (event) => { if (event.target === overlay) close(); });
|
||||
modal.open("chat-usage-info", overlay, {
|
||||
trigger,
|
||||
onClose: close,
|
||||
onClosed: () => {
|
||||
usageInfoSessionId = null;
|
||||
document.getElementById("chatUsageInfo")?.setAttribute("aria-expanded", "false");
|
||||
},
|
||||
fallbackSelectors: ["#chatUsageInfo", "#chatInput", "#detailTitle"],
|
||||
});
|
||||
}
|
||||
|
||||
/** The active conversation: identity, context, transcript and its controls. */
|
||||
function renderChatConversation() {
|
||||
if (usageInfoSessionId && usageInfoSessionId !== state.chatActiveId) modal.close("chat-usage-info");
|
||||
const pane = h("div", { class: "detail chat-detail" });
|
||||
if (!state.chatActiveId) {
|
||||
pane.append(chatEmpty(SELECT_CHAT_HINT));
|
||||
@@ -2552,6 +2590,17 @@ function renderChatConversation() {
|
||||
// brings its card (the transcript's last item) into view — the one scroll path,
|
||||
// so a pending request is reached the same way new content is.
|
||||
if (awaiting) bar.append(approvalJumpButton(chatApprovalCards(thread).some(card=>card.actionable) ? WAITING_FOR_APPROVAL_LABEL : "Answer question"));
|
||||
bar.append(h("button", {
|
||||
id: "chatUsageInfo",
|
||||
class: "ghost chat-usage-info-button",
|
||||
type: "button",
|
||||
title: "Chat information",
|
||||
"aria-label": "Chat information",
|
||||
"aria-haspopup": "dialog",
|
||||
"aria-controls": "chatUsageInfoPanel",
|
||||
"aria-expanded": String(usageInfoSessionId === state.chatActiveId && modal?.isOpen?.("chat-usage-info") === true),
|
||||
onclick: (event) => openChatUsageInfo(state.chatActiveId, event.currentTarget),
|
||||
}, h("span", { class: "chat-usage-info-icon", "aria-hidden": "true", text: "i" })));
|
||||
pane.append(bar);
|
||||
const modelButton = effective ? renderChatModelButton(effective) : null;
|
||||
if (modelButton) {
|
||||
@@ -2559,7 +2608,6 @@ function renderChatConversation() {
|
||||
context.append(modelButton);
|
||||
pane.append(context);
|
||||
}
|
||||
pane.append(renderChatUsageMetrics(thread, state.chatActiveId));
|
||||
|
||||
// The background-tasks bar (C11) sits above the transcript, outside the
|
||||
// scroller so the C14 scroll positions are untouched. It is present only while
|
||||
|
||||
Reference in New Issue
Block a user