web: one chat activity line, clearer groups and paste attachments

Replace the reasoning, tool and bottom thinking rows with one stable activity
line and refresh Stop on the step frame. Make directory and Closed bands share
an elevated square surface, centred text and a collapse toggle. Read pasted
files into the composer attachment path and show sent files in user bubbles.
This commit is contained in:
2026-10-20 14:30:57 +01:00
parent f5ccec8e1f
commit 3799d37d7c
11 changed files with 583 additions and 306 deletions
+27 -1
View File
@@ -61,6 +61,7 @@ export const ROLE_ASSISTANT = "assistant";
export const PART_TEXT = "text";
export const PART_REASONING = "reasoning";
export const PART_TOOL = "tool";
export const PART_FILE = "file";
/** ChatSession.Tag values, and the one display label derived from them. */
export const TAG_OPERATOR = "operator";
@@ -551,6 +552,28 @@ export function sessionActivity(running, unseen) {
return "idle";
}
/**
* How long ago the session last changed, in the list's own words: `just now`,
* `2 min ago`, `3 hr ago`, `2 days ago`, then a short date for older chats. The
* server's `updated_at` is milliseconds, matching the seen watermark.
*/
export function relativeSessionTime(updatedAt, now = Date.now()) {
const then = millis(updatedAt);
if (then <= 0) return "";
const elapsed = Math.max(0, Number(now) - then);
const seconds = Math.floor(elapsed / 1000);
if (seconds < 45) return "just now";
const minutes = Math.max(1, Math.floor(seconds / 60));
if (minutes < 60) return `${minutes} min ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours} hr ago`;
const days = Math.floor(hours / 24);
if (days < 7) return days === 1 ? "1 day ago" : `${days} days ago`;
return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short" }).format(
new Date(then),
);
}
/**
* The activity badge word, or null when the row shows none. An idle session
* shows `Open` only while its conversation is open; a streaming or unseen one
@@ -1578,13 +1601,16 @@ function applyRemoteUser(thread, frame) {
return thread;
}
if (messages.some((message) => message?.id === messageId)) return thread;
const files = (frame?.attachments ?? []).filter(
(part) => part?.type === PART_FILE && (str(part?.name) !== "" || str(part?.uri) !== ""),
);
const message = {
id: messageId,
session_id: str(frame?.session_id),
role: ROLE_USER,
client: str(frame?.client),
operation_id: operationId,
parts: [{ type: PART_TEXT, text }],
parts: [{ type: PART_TEXT, text }, ...files],
};
return { ...thread, messages: [...messages, message] };
}