web: give chat details a real back route

Opening a chat now pushes /chat/:id, so Android/browser Back returns to the
chat list rather than the previous destination. The conversation header owns a
compact Back to chats control matching the create pane, replacing the
full-width Back to list row on phones.
This commit is contained in:
2026-10-20 03:25:31 +01:00
parent 526c19fc21
commit c291327610
6 changed files with 90 additions and 10 deletions
+23 -2
View File
@@ -256,6 +256,7 @@ export function createChatView(rt) {
let chatNow = Date.now();
const renderContent = (...args) => rt.renderContent(...args);
const focusDetailHeading = (...args) => rt.focusDetailHeading(...args);
const closeDetail = (...args) => rt.closeDetail?.(...args);
const renderActionFailedDialog = (...args) => rt.views.dialogs.renderActionFailedDialog(...args);
/** Remember one conversation's scroll position (index of the first visible row). */
@@ -491,7 +492,9 @@ async function createNewChat() {
}
/** Open a session: select it, subscribe its stream and load its newest history page. */
async function openChatSession(id) {
async function openChatSession(id, { updateRoute = true } = {}) {
if (updateRoute) rt.pushRoute({ kind: "chatSession", id });
state.view = "chat";
if (state.chatActiveId === id && state.chatThreads.get(id)?.loaded) return;
// Remember where the operator left the conversation being closed.
const leaving = document.getElementById("chatTranscript");
@@ -1954,11 +1957,29 @@ function renderChatConversation() {
const awaiting = approval?.actionable === true || form != null;
const bar = h("div", { class: "chat-bar" });
const lead = h("div", { class: "chat-bar-lead" });
// A compact back control in the conversation header, matching the create
// pane's own. The narrow layout is where the list is covered; on wide screens
// the list is still visible, so CSS hides it there.
lead.append(
h(
"button",
{
class: "ghost chat-create-back 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: "←" }),
),
);
const titles = h("div", { class: "chat-bar-titles" });
// The open conversation is the route's one h1; the list heading above becomes
// its h2 while the detail is open.
titles.append(h("h1", { class: "chat-bar-title", id: "detailTitle", tabindex: "-1", text: title }));
bar.append(titles);
lead.append(titles);
bar.append(lead);
if (thread?.hasMore) {
bar.append(
h("button", {