Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Unread dots for web conversations; remove conversation status (#2250)

Regan Bell3cb78953ba96
diff --git a/plugins/web-ui/server/index.ts b/plugins/web-ui/server/index.ts
index 34afcbdd9..7a0e6b42b 100644
--- a/plugins/web-ui/server/index.ts
+++ b/plugins/web-ui/server/index.ts
@@ -2123,24 +2123,34 @@ const apiRoutes: readonly WebRoute[] = [
handle: async (c) => {
const { req, res, user } = c;
const id = c.params.id!;
- const p = await readJson<{ title?: unknown; archived?: unknown; pinned?: unknown; color?: unknown }>(
- req,
- res,
- false,
- );
+ const p = await readJson<{
+ title?: unknown;
+ archived?: unknown;
+ pinned?: unknown;
+ color?: unknown;
+ unread?: unknown;
+ }>(req, res, false);
if (!p) return;
- const patch: { title?: string | null; archived?: boolean; pinned?: boolean; color?: string | null } = {};
+ const patch: {
+ title?: string | null;
+ archived?: boolean;
+ pinned?: boolean;
+ color?: string | null;
+ unread?: boolean;
+ } = {};
if (p.title === null || typeof p.title === "string") patch.title = p.title as string | null;
if (typeof p.archived === "boolean") patch.archived = p.archived;
if (typeof p.pinned === "boolean") patch.pinned = p.pinned;
if (p.color === null || typeof p.color === "string") patch.color = p.color as string | null;
+ if (typeof p.unread === "boolean") patch.unread = p.unread;
if (
patch.title === undefined &&
patch.archived === undefined &&
patch.pinned === undefined &&
- patch.color === undefined
+ patch.color === undefined &&
+ patch.unread === undefined
) {
- return json(res, 400, { error: "bad_request", message: "title, archived, pinned, or color required" });
+ return json(res, 400, { error: "bad_request", message: "title, archived, pinned, color, or unread required" });
}
return relayCore(
res,
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.ts
index 6c9cdbcf0..dac83456b 100644
--- a/plugins/web-ui/src/chat.ts
+++ b/plugins/web-ui/src/chat.ts
@@ -1619,7 +1619,6 @@ export function createChatSurface(
? chatState.forkSession.forkedFrom
: undefined;
return sessionTopbarTpl({
- status: session?.status,
sessionId: chatState.sessionId ?? session?.id,
crumb,
title,
diff --git a/plugins/web-ui/src/conversations.ts b/plugins/web-ui/src/conversations.ts
index 15c76ad5b..5465abe94 100644
--- a/plugins/web-ui/src/conversations.ts
+++ b/plugins/web-ui/src/conversations.ts
@@ -96,6 +96,7 @@ export function ensureDeliveryStream(): void {
if (matched) {
sessionsState.list = list;
renderList();
+ if (event.state === "idle") void refreshSessions({ silent: true });
const parentId = list.find((session) => session.threadRef === event.threadRef)?.parentSessionId;
if (parentId) for (const conv of live) if (conv.state.sessionId === parentId) conv.redraw();
} else {
diff --git a/plugins/web-ui/src/core-bridge.ts b/plugins/web-ui/src/core-bridge.ts
index 557199e98..5e0270e50 100644
--- a/plugins/web-ui/src/core-bridge.ts
+++ b/plugins/web-ui/src/core-bridge.ts
@@ -126,7 +126,6 @@ export interface DeliveredFile {
}
export interface CoreSession {
- status?: { emoji: string; text: string } | null;
id: string;
type: "dm" | "channel" | "group";
scopeId: string;
@@ -137,6 +136,7 @@ export interface CoreSession {
archived?: boolean;
pinned?: boolean;
color?: string | null;
+ unread?: boolean;
lastActivityAt?: number;
working?: boolean;
awaitingInput?: boolean;
@@ -285,7 +285,7 @@ function browserTimezone(): string {
export async function updateSession(
id: string,
- patch: { title?: string | null; archived?: boolean; pinned?: boolean; color?: string | null },
+ patch: { title?: string | null; archived?: boolean; pinned?: boolean; color?: string | null; unread?: boolean },
): Promise<{ session: CoreSession }> {
return api<{ session: CoreSession }>(`/api/sessions/${encodeURIComponent(id)}`, {
method: "POST",
diff --git a/plugins/web-ui/src/session-scope.ts b/plugins/web-ui/src/session-scope.ts
index 8ae27316f..4d103928e 100644
--- a/plugins/web-ui/src/session-scope.ts
+++ b/plugins/web-ui/src/session-scope.ts
@@ -1,5 +1,3 @@
-import { sessionStatusMark } from "./session-status.ts";
-import type { CoreSession } from "./core-bridge.ts";
import { html, nothing, type TemplateResult } from "lit";
import { ArrowUpLeft, Box, Brain, Clock3, Ellipsis, Files, GitFork, KeyRound, Rocket } from "lucide";
import { api } from "./core-bridge";
@@ -78,7 +76,6 @@ export function scopeToolCount(tool: SessionTool, scope: string, onReady: () =>
export type SessionTool = "crons" | "files" | "memory" | "apps" | "skills" | "keychain";
export interface SessionTopbarOpts {
- status?: CoreSession["status"];
sessionId?: string | null;
crumb: string | null;
title: string;
@@ -181,7 +178,6 @@ export function sessionTopbarTpl(o: SessionTopbarOpts): TemplateResult {
</button>`
: html`<div class="session-heading">${heading}</div>`
}
- ${sessionStatusMark(o.status)}
<div class="topbar-actions session-tools">
${tool("crons", Clock3, "Crons")} ${tool("apps", Rocket, "Apps")} ${tool("files", Files, "Files")}
${tool("skills", Box, "Skills")} ${tool("memory", Brain, "Memory")}
diff --git a/plugins/web-ui/src/session-status.ts b/plugins/web-ui/src/session-status.ts
deleted file mode 100644
index 4e6c60183..000000000
--- a/plugins/web-ui/src/session-status.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { html, nothing } from "lit";
-import type { CoreSession } from "./core-bridge.ts";
-import { tip } from "./tooltip.ts";
-
-export function sessionStatusMark(status: CoreSession["status"]) {
- return status
- ? html`<span class="session-status" role="img" tabindex="0" aria-label=${status.text} ${tip(status.text)}
- >${status.emoji}</span
- >`
- : nothing;
-}
diff --git a/plugins/web-ui/src/sessions.ts b/plugins/web-ui/src/sessions.ts
index b363f2473..1ac60d380 100644
--- a/plugins/web-ui/src/sessions.ts
+++ b/plugins/web-ui/src/sessions.ts
@@ -1,4 +1,3 @@
-import { sessionStatusMark } from "./session-status.ts";
import { openSessionShare } from "./session-share";
import { html, nothing, render, type TemplateResult } from "lit";
import { live } from "lit/directives/live.js";
@@ -21,6 +20,8 @@ import {
Hash,
Link,
Lock,
+ Mail,
+ MailOpen,
Palette,
Pencil,
Pin,
@@ -115,7 +116,14 @@ export const sessionsState = {
};
let selection: SessionSelection = emptySelection();
-type SessionPatch = { title?: string | null; archived?: boolean; pinned?: boolean; color?: string | null };
+type SessionPatch = {
+ title?: string | null;
+ archived?: boolean;
+ pinned?: boolean;
+ color?: string | null;
+ unread?: boolean;
+};
+let keptUnreadId: string | null = null;
const sessionPatchTails = new Map<string, Promise<void>>();
const sessionPatchVersions = new Map<string, number>();
let sessionPatchGeneration = 0;
@@ -326,6 +334,7 @@ function visibleSessions(): CoreSession[] {
}
export function renderList(): void {
+ markOpenSessionsRead();
syncDocumentTitle();
if (chatsPageShowing()) drawChatsPage();
if (!appState.listEl) return;
@@ -810,7 +819,7 @@ function chatPageRow(s: CoreSession): TemplateResult {
>
<span class="list-row-title">${statusMarks(s)}<span dir="auto">${groupDmTitle(s)}</span></span>
<span class="list-row-meta">
- ${sessionStatusMark(s.status)} ${scopeChip(s.scopeId, s.channelName ?? null)}
+ ${unreadDot(s)} ${scopeChip(s.scopeId, s.channelName ?? null)}
${surfaceOf(s) === "slack" ? html`<span class="surface surface-slack">${slackLogo(13)}</span>` : nothing}
${readOnly ? html`<span class="ro-lock" ${tip("Read-only")}>${icon(Lock, 12)}</span>` : nothing}
<span class="list-row-date">${listWhen(activityOf(s))}</span>
@@ -989,6 +998,7 @@ function sessionRow(s: CoreSession, projectChild = false): TemplateResult {
working ? "agent is working" : null,
s.awaitingInput ? "waiting for your reply" : null,
readOnly ? "read-only" : null,
+ showsUnread(s) ? "unread" : null,
s.pinned ? "pinned" : null,
selection.ids.has(s.id) ? "selected" : null,
relTime(activityOf(s)),
@@ -998,7 +1008,7 @@ function sessionRow(s: CoreSession, projectChild = false): TemplateResult {
return html`
<div
data-session-id=${saved ? s.id : nothing}
- class="session-row ${active ? "active" : ""} ${saved && selection.ids.has(s.id) ? "selected" : ""} ${menuOpen ? "menu-open" : ""} ${readOnly ? "read-only" : ""} ${refreshingTitle ? "title-refreshing" : ""} ${working ? "working" : ""} ${s.awaitingInput ? "awaiting-input" : ""} ${projectChild ? "project-child" : ""} ${color ? "colored" : ""}"
+ class="session-row ${active ? "active" : ""} ${saved && selection.ids.has(s.id) ? "selected" : ""} ${menuOpen ? "menu-open" : ""} ${readOnly ? "read-only" : ""} ${refreshingTitle ? "title-refreshing" : ""} ${working ? "working" : ""} ${s.awaitingInput ? "awaiting-input" : ""} ${showsUnread(s) ? "unread" : ""} ${projectChild ? "project-child" : ""} ${color ? "colored" : ""}"
style=${color ? `--session-color:${color}` : nothing}
>
<a
@@ -1046,13 +1056,20 @@ function sessionRow(s: CoreSession, projectChild = false): TemplateResult {
e.preventDefault();
startRename(s);
}}
+ @contextmenu=${(e: MouseEvent) => {
+ if (!saved) return;
+ e.preventDefault();
+ e.stopPropagation();
+ sessionsState.openMenuId = s.id;
+ renderList();
+ }}
>
<div class="title" aria-live="polite">
${statusMarks(s)}${surfaceGlyph(s)}${readOnly ? html`<span class="ro-lock" ${tip("Read-only")}>${icon(Lock, 12)}</span>` : nothing}<span
class="tl"
dir="auto"
>${titleContent}</span
- >${context ? html`<span class="row-context" ${tip(context)}>${context}</span>` : nothing}
+ >${context ? html`<span class="row-context" ${tip(context)}>${context}</span>` : nothing}${unreadDot(s)}
</div>
</a>
${
@@ -1094,7 +1111,7 @@ function sessionRow(s: CoreSession, projectChild = false): TemplateResult {
>
${icon(EllipsisVertical, 15)}
</button>
- ${sessionStatusMark(s.status)} ${menuOpen ? sessionMenuPopover(s) : nothing}
+ ${menuOpen ? sessionMenuPopover(s) : nothing}
</div>`
: nothing
}
@@ -1185,6 +1202,9 @@ function sessionMenuPopover(s: CoreSession): TemplateResult {
<button class="session-menu-option" type="button" role="menuitem" @click=${() => void copySessionLink(s)}>
${icon(Link, 15)}<span>Copy link</span>
</button>
+ <button class="session-menu-option" type="button" role="menuitem" @click=${() => setUnread(s, !s.unread)}>
+ ${s.unread ? icon(MailOpen, 15) : icon(Mail, 15)}<span>${s.unread ? "Mark as read" : "Mark as unread"}</span>
+ </button>
<button class="session-menu-option" type="button" role="menuitem" @click=${() => setPinned(s, !pinned)}>
${pinned ? icon(PinOff, 15) : icon(Pin, 15)}<span>${pinned ? "Unpin" : "Pin"}</span>
</button>
@@ -1523,6 +1543,27 @@ function setArchived(s: CoreSession, archived: boolean): void {
void persistSessionPatch(s.id, { archived });
}
+function setUnread(s: CoreSession, unread: boolean): void {
+ sessionsState.openMenuId = null;
+ keptUnreadId = unread && openConversationIds().includes(s.id) ? s.id : null;
+ void persistSessionPatch(s.id, { unread });
+}
+
+function showsUnread(s: CoreSession): boolean {
+ return Boolean(s.id && s.unread && (keptUnreadId === s.id || !openConversationIds().includes(s.id)));
+}
+
+function unreadDot(s: CoreSession): TemplateResult | typeof nothing {
+ return showsUnread(s) ? html`<span class="unread-dot" role="img" aria-label="Unread"></span>` : nothing;
+}
+
+function markOpenSessionsRead(): void {
+ const open = new Set(openConversationIds());
+ for (const s of sessionsState.list) {
+ if (s.unread && open.has(s.id) && s.id !== keptUnreadId) void persistSessionPatch(s.id, { unread: false });
+ }
+}
+
function setPinned(s: CoreSession, pinned: boolean): void {
sessionsState.openMenuId = null;
void persistSessionPatch(s.id, { pinned });
@@ -1547,6 +1588,7 @@ function applyResolvedSession(updated: CoreSession): void {
archived: Boolean(updated.archived),
pinned: Boolean(updated.pinned),
color: updated.color ?? null,
+ unread: Boolean(updated.unread),
}
: s,
);
@@ -1740,6 +1782,7 @@ export async function openSession(
approvalsPrefetch?: Promise<{ approvals: PendingApproval[] } | null>,
): Promise<void> {
if (pendingForkThreads.has(s.threadRef)) return;
+ if (keptUnreadId !== s.id) keptUnreadId = null;
if (appState.currentView !== "chats") {
appState.currentView = "chats";
appState.viewRenderSeq++;
@@ -1763,6 +1806,7 @@ export async function openSessionInto(
tracked = conv === mainConversation(),
): Promise<void> {
if (pendingForkThreads.has(s.threadRef)) return;
+ if (keptUnreadId !== s.id) keptUnreadId = null;
if (!s.id) {
if (conv.state.threadRef !== s.threadRef) {
conv.mountContinuable(s.threadRef, null, s.scopeId || null, [], s.channelName ?? null);
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index f214cef6b..654f27b08 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -589,7 +589,7 @@ a.chat-row-open {
box-sizing: border-box;
text-align: left;
- padding: 5px calc(5px + var(--session-status-space, 0px)) 5px 11px;
+ padding: 5px 5px 5px 11px;
border: 0;
border-radius: var(--radius-sm);
background: transparent;
@@ -601,7 +601,7 @@ a.chat-row-open {
.session-row:hover .session,
.session-row:focus-within .session,
.session-row.menu-open .session {
- padding-right: calc(90px + var(--session-status-space, 0px));
+ padding-right: 90px;
}
.session:hover {
background: var(--conversation-hover);
@@ -665,23 +665,21 @@ a.chat-row-open {
white-space: nowrap;
}
-.session-status {
- display: inline-flex;
- flex: none;
- align-items: center;
- font-size: var(--font-14);
- line-height: 1;
-}
-
-.session-row:has(.session-status) {
- --session-status-space: 22px;
+.unread-dot {
+ flex: 0 0 auto;
+ width: 8px;
+ height: 8px;
+ margin-left: 8px;
+ border-radius: 50%;
+ background: var(--unread-dot, #2f81f7);
}
-.session-menu > .session-status {
- justify-content: center;
- width: 20px;
+.session-row:hover .unread-dot,
+.session-row:focus-within .unread-dot,
+.session-row.menu-open .unread-dot {
+ visibility: hidden;
}
-.split-pane-title > .session-status {
- margin-inline-start: auto;
+.session-row.unread .title .tl {
+ font-weight: 600;
}
.working-mark {
display: inline-flex;
@@ -5988,7 +5986,7 @@ a.connector-widget:focus-visible {
.session-row:hover .session,
.session-row:focus-within .session,
.session-row.menu-open .session {
- padding-right: calc(136px + var(--session-status-space, 0px));
+ padding-right: 136px;
}
.session-menu {
right: 0;
@@ -8957,17 +8955,6 @@ h3.ambient-field-label {
align-self: anchor-center;
position-try-fallbacks: --qm-tooltip-above, --qm-tooltip-below;
}
-.qm-tooltip.sidebar-status {
- position-area: right span-all;
- left: anchor(--qm-sidebar right);
- justify-self: normal;
- align-self: anchor-center;
- margin: 8px;
- padding: 8px 10px;
- border-radius: var(--radius-sm);
- line-height: 1.5;
- position-try-fallbacks: --qm-tooltip-above, --qm-tooltip-below;
-}
@position-try --qm-tooltip-above {
left: auto;
position-area: top span-all;
@@ -11307,7 +11294,7 @@ h3.ambient-field-label {
.session-row:hover .session,
.session-row:focus-within .session,
.session-row.menu-open .session {
- padding-right: calc(48px + var(--session-status-space, 0px));
+ padding-right: 48px;
}
.user-pill {
min-height: 44px;
diff --git a/plugins/web-ui/src/split.ts b/plugins/web-ui/src/split.ts
index 98964afaa..4f5bf8cfb 100644
--- a/plugins/web-ui/src/split.ts
+++ b/plugins/web-ui/src/split.ts
@@ -1,4 +1,3 @@
-import { sessionStatusMark } from "./session-status.ts";
import { openSessionShare } from "./session-share";
import { preserveTranscriptScroll } from "./transcript-viewport";
import { html, nothing, render, type TemplateResult } from "lit";
@@ -812,7 +811,7 @@ function computeHeaderSignature(): string {
const parent = session?.parentSessionId
? sessionsState.list.find((row) => row.id === session.parentSessionId)
: undefined;
- return `${p.id}|${session?.id ?? ""}|${paneCrumb(p) ?? ""}|${paneTitle(p)}|${JSON.stringify(session?.status ?? null)}|${paneIsWorking(p)}|${paneAwaitsInput(p)}|${paneBackground(p)?.label ?? ""}|${paneKindBadge(p)}|${session?.parentSessionId ?? ""}|${parent?.title ?? ""}`;
+ return `${p.id}|${session?.id ?? ""}|${paneCrumb(p) ?? ""}|${paneTitle(p)}|${paneIsWorking(p)}|${paneAwaitsInput(p)}|${paneBackground(p)?.label ?? ""}|${paneKindBadge(p)}|${session?.parentSessionId ?? ""}|${parent?.title ?? ""}`;
})
.join("~");
}
@@ -1266,7 +1265,6 @@ class PaneTab implements ITabRenderer {
: nothing
}
<span class="split-pane-title-text" dir="auto">${title}</span>
- ${sessionStatusMark(paneSession(panel)?.status)}
${
this.inStrip
? html`<span class="split-tab-actions">
diff --git a/plugins/web-ui/src/tooltip.ts b/plugins/web-ui/src/tooltip.ts
index 393131ae0..ea8681b8f 100644
--- a/plugins/web-ui/src/tooltip.ts
+++ b/plugins/web-ui/src/tooltip.ts
@@ -26,7 +26,6 @@ function showTooltip(target: Element, text: string): void {
target.setAttribute("data-qm-tooltip-anchor", "");
const el = ensureEl();
el.textContent = text;
- el.classList.toggle("sidebar-status", target.matches(".sidebar .session-status"));
el.classList.toggle("beside", !!target.closest('[data-tip-placement="right"]'));
el.classList.add("visible");
el.showPopover?.();
diff --git a/plugins/web-ui/test/session-scope.test.ts b/plugins/web-ui/test/session-scope.test.ts
index af41a697f..045b00dce 100644
--- a/plugins/web-ui/test/session-scope.test.ts
+++ b/plugins/web-ui/test/session-scope.test.ts
@@ -16,7 +16,6 @@ for (const [key, value] of Object.entries({
}))
Object.defineProperty(globalThis, key, { configurable: true, value });
const { html, nothing, render } = await import("lit");
-const { sessionStatusMark } = await import("../src/session-status.ts");
function load(api: (path: string) => Promise<unknown> = async () => ({})) {
return runInNewContext(
@@ -26,7 +25,6 @@ function load(api: (path: string) => Promise<unknown> = async () => ({})) {
{
api,
html,
- sessionStatusMark,
nothing,
icon: () => nothing,
tip: () => nothing,
@@ -155,21 +153,3 @@ test("zero counts remain hidden in desktop and mobile tools", () => {
render(load().sessionTopbarTpl({ crumb: null, title: "Test", onTool: () => {}, toolCount: () => 0 }), host);
assert.equal(host.querySelectorAll(".session-tool-count").length, 0);
});
-
-test("session status appears after the heading and before tools", () => {
- const host = document.createElement("div");
- render(
- load().sessionTopbarTpl({
- crumb: null,
- title: "Release verification",
- status: { emoji: "πŸš€", text: "Live in production" },
- onTool: () => {},
- }),
- host,
- );
- const status = host.querySelector(".session-status")!;
- assert.equal(status.textContent, "πŸš€");
- assert.equal(status.getAttribute("aria-label"), "Live in production");
- assert.ok(status.previousElementSibling?.classList.contains("session-heading"));
- assert.ok(status.nextElementSibling?.classList.contains("session-tools"));
-});
diff --git a/plugins/web-ui/test/session-status.test.ts b/plugins/web-ui/test/session-status.test.ts
deleted file mode 100644
index a67cd1756..000000000
--- a/plugins/web-ui/test/session-status.test.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { test } from "node:test";
-import assert from "node:assert/strict";
-import { JSDOM } from "jsdom";
-
-const dom = new JSDOM("<div id='root'></div>");
-Object.assign(globalThis, {
- document: dom.window.document,
- window: dom.window,
- HTMLElement: dom.window.HTMLElement,
- customElements: dom.window.customElements,
-});
-const { render } = await import("lit");
-const { sessionStatusMark } = await import("../src/session-status.ts");
-const root = document.getElementById("root")!;
-
-test("session status renders safe text, exposes a keyboard tooltip, updates and clears", () => {
- render(sessionStatusMark({ emoji: "βœ…", text: "PR merged <script>" }), root);
- const mark = root.querySelector<HTMLElement>(".session-status")!;
- assert.equal(mark.textContent, "βœ…");
- assert.equal(mark.getAttribute("aria-label"), "PR merged <script>");
- mark.dispatchEvent(new dom.window.FocusEvent("focus"));
- assert.equal(document.querySelector(".qm-tooltip")?.textContent, "PR merged <script>");
- assert.equal(document.querySelector("script"), null);
- render(sessionStatusMark({ emoji: "πŸš€", text: "Live in production" }), root);
- assert.equal(mark.textContent, "πŸš€");
- assert.equal(document.querySelector(".qm-tooltip")?.textContent, "Live in production");
- render(sessionStatusMark(null), root);
- assert.equal(root.querySelector(".session-status"), null);
- assert.equal(document.querySelector(".qm-tooltip.visible"), null);
-});
diff --git a/src/api/agent-api-catalog.ts b/src/api/agent-api-catalog.ts
index 0ca6da98d..e0a1fc977 100644
--- a/src/api/agent-api-catalog.ts
+++ b/src/api/agent-api-catalog.ts
@@ -399,7 +399,7 @@ const FAMILIES: AgentApiFamily[] = [
method: "GET",
path: "/v1/conversations",
summary:
- "list the asking person's own conversations (id, title, status, archived, pinned, lastActivityAt) β€” the same list their web sidebar shows",
+ "list the asking person's own conversations (id, title, archived, pinned, unread, lastActivityAt) β€” the same list their web sidebar shows",
},
{
method: "GET",
@@ -411,7 +411,6 @@ const FAMILIES: AgentApiFamily[] = [
},
{
match: () => false,
- when: (v) => v.claims.surface === "slack",
routes: [
{
method: "POST",
@@ -420,17 +419,6 @@ const FAMILIES: AgentApiFamily[] = [
},
],
},
- {
- match: () => false,
- when: (v) => v.claims.surface !== "slack",
- routes: [
- {
- method: "POST",
- path: "/v1/conversations/:id",
- summary: `${CONVERSATION_UPDATE} Body status sets the web UI sidebar status shared by everyone in the session: {emoji: one Unicode emoji, text: 1–200 characters}, or null to clear. Use it for verified milestones, e.g. βœ… PR merged or πŸš€ Live in production, and replace it as work progresses. 404 for a conversation not on their list`,
- },
- ],
- },
{
match: (m, p) => m === "GET" && (p === "/v1/files" || /^\/v1\/files\/[^/]+\/content$/.test(p)),
guidance:
diff --git a/src/api/app-sessions.ts b/src/api/app-sessions.ts
index 2496cf405..e9c05037e 100644
--- a/src/api/app-sessions.ts
+++ b/src/api/app-sessions.ts
@@ -9,7 +9,6 @@ import {
SUBAGENT_TREE_RUN_CAP,
workingSessionThreadRefs,
} from "../sessions/session-syscalls.ts";
-import { isSessionStatus } from "../sessions/session-status.ts";
import type { PendingApprovalRecord } from "../types.ts";
import { orgId as orgIdOf } from "../config.ts";
import { parseScopeId, scopeId } from "../types.ts";
@@ -843,23 +842,7 @@ export function createSessionMethods(
async updateSession(sessionId, principalId, patch) {
const session = await sessionForViewer(sessionId, principalId);
if (!session) return null;
- const { status, ...view } = patch;
- if (status !== undefined) {
- const participants = await deps.sessions.participantWindowsOf(sessionId);
- if (!participants.some((p) => p.principalId === principalId && p.validTo === null)) return null;
- if (!isSessionStatus(status)) throw new Error("invalid session status");
- await deps.sessions.updateStatus(sessionId, status ? { emoji: status.emoji, text: status.text.trim() } : null);
- }
- await deps.sessions.updateParticipantView(sessionId, principalId, view);
- if (status !== undefined) {
- deps.sessionStateBus?.emit({
- threadRef: session.threadRef,
- sessionId,
- participants: await deps.sessions.participantsOf(sessionId),
- state: "metadata",
- at: Date.now(),
- });
- }
+ await deps.sessions.updateParticipantView(sessionId, principalId, patch);
return sessionForViewer(sessionId, principalId);
},
diff --git a/src/api/app-types.ts b/src/api/app-types.ts
index 7da2db8fe..94a61d9cc 100644
--- a/src/api/app-types.ts
+++ b/src/api/app-types.ts
@@ -390,7 +390,7 @@ export interface App {
archived?: boolean;
pinned?: boolean;
color?: string | null;
- status?: Session["status"];
+ readAt?: number;
},
): Promise<Session | null>;
regenerateTitle(sessionId: string, principalId: string): Promise<{ title: string | null } | null>;
diff --git a/src/api/routes/surface.ts b/src/api/routes/surface.ts
index 760f52c62..be9679230 100644
--- a/src/api/routes/surface.ts
+++ b/src/api/routes/surface.ts
@@ -1,6 +1,5 @@
import { memoryForRequest } from "./memory-access.ts";
import type { MemoryEdit, MemoryService } from "../../memory/memory-service.ts";
-import { isSessionStatus } from "../../sessions/session-status.ts";
import { suggestedActivityRoutes } from "./suggested-activities.ts";
import { runtimeFallback, runtimeConfigBody, userRuntimeConfigBody, webuiModelEnabled } from "../runtime-config.ts";
import { canReadNotebook, searchAcrossScopes } from "../../memory/cross-scope.ts";
@@ -114,7 +113,6 @@ function agentConversation(session: Session) {
return {
id: session.id,
title: session.title,
- status: session.status,
type: session.type,
scopeId: session.scopeId,
threadRef: session.threadRef,
@@ -123,6 +121,7 @@ function agentConversation(session: Session) {
archived: session.archived === true,
pinned: session.pinned === true,
color: session.color ?? null,
+ unread: session.unread === true,
lastActivityAt: session.lastActivityAt ?? session.createdAt,
};
}
@@ -339,7 +338,7 @@ async function patchSession(ctx: ApiCtx): Promise<void> {
archived?: unknown;
pinned?: unknown;
color?: unknown;
- status?: unknown;
+ unread?: unknown;
};
const principalId = typeof b.principalId === "string" ? b.principalId : null;
if (!principalId) return sendJson(res, 400, { error: "bad_request", message: "principalId required" });
@@ -348,8 +347,14 @@ async function patchSession(ctx: ApiCtx): Promise<void> {
archived?: boolean;
pinned?: boolean;
color?: string | null;
- status?: Session["status"];
+ readAt?: number;
} = {};
+ if ("unread" in b) {
+ if (typeof b.unread !== "boolean") {
+ return sendJson(res, 400, { error: "bad_request", message: "unread must be a boolean" });
+ }
+ patch.readAt = b.unread ? 0 : Date.now();
+ }
if ("title" in b) {
if (b.title !== null && typeof b.title !== "string") {
return sendJson(res, 400, { error: "bad_request", message: "title must be a string or null" });
@@ -375,23 +380,17 @@ async function patchSession(ctx: ApiCtx): Promise<void> {
}
patch.color = typeof b.color === "string" ? b.color.toLowerCase() : null;
}
- if ("status" in b) {
- if (!isSessionStatus(b.status)) {
- return sendJson(res, 400, {
- error: "bad_request",
- message: "status must be null or {emoji: one Unicode emoji, text: 1–200 characters without control characters}",
- });
- }
- patch.status = b.status;
- }
if (
patch.title === undefined &&
patch.archived === undefined &&
patch.pinned === undefined &&
patch.color === undefined &&
- patch.status === undefined
+ patch.readAt === undefined
) {
- return sendJson(res, 400, { error: "bad_request", message: "title, archived, pinned, color, or status required" });
+ return sendJson(res, 400, {
+ error: "bad_request",
+ message: "title, archived, pinned, color, or unread required",
+ });
}
const session = await app.updateSession(id, principalId, patch);
if (!session) return sendJson(res, 404, { error: "not_found" });
@@ -420,7 +419,6 @@ async function patchAgentConversation(ctx: ApiCtx): Promise<void> {
archived?: boolean;
pinned?: boolean;
color?: string | null;
- status?: Session["status"];
} = {};
if ("archived" in b) {
if (typeof b.archived !== "boolean") {
@@ -447,29 +445,13 @@ async function patchAgentConversation(ctx: ApiCtx): Promise<void> {
}
patch.color = typeof b.color === "string" ? b.color.toLowerCase() : null;
}
- if ("status" in b) {
- if (capability.surface === "slack") {
- return sendJson(res, 403, {
- error: "forbidden",
- message: "conversation status is a web UI feature and is not available on Slack turns",
- });
- }
- if (!isSessionStatus(b.status)) {
- return sendJson(res, 400, {
- error: "bad_request",
- message: "status must be null or {emoji: one Unicode emoji, text: 1–200 characters without control characters}",
- });
- }
- patch.status = b.status;
- }
if (
patch.archived === undefined &&
patch.pinned === undefined &&
patch.title === undefined &&
- patch.color === undefined &&
- patch.status === undefined
+ patch.color === undefined
) {
- return sendJson(res, 400, { error: "bad_request", message: "archived, pinned, title, color, or status required" });
+ return sendJson(res, 400, { error: "bad_request", message: "archived, pinned, title, or color required" });
}
const session = await app.updateSession(ctx.params.id!, capability.actorId, patch);
if (!session) return sendJson(res, 404, { error: "not_found", message: "not a conversation you can see" });
@@ -484,7 +466,6 @@ async function patchAgentConversation(ctx: ApiCtx): Promise<void> {
conversation: {
...agentConversation(session),
...(patch.title !== undefined ? { title: patch.title } : {}),
- ...(patch.status !== undefined ? { status: patch.status } : {}),
},
});
}
diff --git a/src/sessions/memory-session-store.ts b/src/sessions/memory-session-store.ts
index 31c4a0829..501ebea9a 100644
--- a/src/sessions/memory-session-store.ts
+++ b/src/sessions/memory-session-store.ts
@@ -45,6 +45,7 @@ import {
userMessagePreview,
tapeTranscriptEntryRecord,
transcriptEntryFromTape,
+ isWebThread,
} from "./session-store.ts";
import { SECURITY_SCREEN_STEP, screenPayloadFromEnvelope } from "../security/security-posture.ts";
@@ -96,6 +97,7 @@ export function createMemorySessionStore(opts: StoreOptions = {}): SessionStore
archived?: boolean;
pinned?: boolean;
color?: string | null;
+ readAt?: number;
}
>
>();
@@ -109,12 +111,16 @@ export function createMemorySessionStore(opts: StoreOptions = {}): SessionStore
const log = all.filter((e) => e.type === "user");
const lastActivityAt = log.length ? Math.max(s.createdAt, ...log.map((e) => e.createdAt)) : s.createdAt;
const visible = view ? all.some((e) => entryWithinTenure(e, view)) : false;
+ const replies = all.filter((e) => e.type === "assistant" || e.type === "delivery");
+ const lastReply = replies.length ? Math.max(...replies.map((e) => e.createdAt)) : null;
+ const unread = lastReply !== null && lastReply > (view?.readAt ?? 0) && isWebThread(s.threadRef);
return {
...s,
...(view?.title != null ? { title: view.title } : {}),
...(view?.archived ? { archived: true } : {}),
...(view?.pinned ? { pinned: true } : {}),
...(view?.color != null ? { color: view.color } : {}),
+ ...(unread ? { unread: true } : {}),
lastActivityAt,
hasEntries: visible,
};
@@ -161,11 +167,6 @@ export function createMemorySessionStore(opts: StoreOptions = {}): SessionStore
if (s) s.title = title;
},
- async updateStatus(sessionId, status) {
- const s = sessions.get(sessionId);
- if (s) s.status = status ? { ...status } : null;
- },
-
async updateForkProvenance(sessionId, provenance) {
const s = sessions.get(sessionId);
if (s) Object.assign(s, provenance);
@@ -568,6 +569,7 @@ export function createMemorySessionStore(opts: StoreOptions = {}): SessionStore
if (patch.archived !== undefined) view.archived = patch.archived;
if (patch.pinned !== undefined) view.pinned = patch.pinned;
if (patch.color !== undefined) view.color = patch.color;
+ if (patch.readAt !== undefined) view.readAt = patch.readAt;
},
async addPin(sessionId, pin: NewSessionPin, maxPins?: number): Promise<SessionPin | null> {
diff --git a/src/sessions/postgres-session-store.ts b/src/sessions/postgres-session-store.ts
index 684d763ca..11f4fae9d 100644
--- a/src/sessions/postgres-session-store.ts
+++ b/src/sessions/postgres-session-store.ts
@@ -53,6 +53,7 @@ import {
threadRefCronIdExpr,
userMessagePreview,
tapeTranscriptEntryRecord,
+ isWebThread,
} from "./session-store.ts";
import { SECURITY_SCREEN_STEP, screenPayloadFromEnvelope } from "../security/security-posture.ts";
@@ -78,7 +79,6 @@ export function rowToSession(r: Record<string, unknown>): Session {
threadRef: r.thread_ref as string,
...(r.surface != null ? { surface: r.surface as string } : {}),
createdAt: Number(r.created_at),
- ...(r.status != null ? { status: r.status as Session["status"] } : {}),
...(r.title != null ? { title: r.title as string } : {}),
...(r.channel_name != null ? { channelName: r.channel_name as string } : {}),
...(r.forked_from_session_id != null && r.fork_boundary_seq != null
@@ -101,6 +101,8 @@ function rowToParticipantSession(r: Record<string, unknown>): Session {
if (r.p_archived) s.archived = true;
if (r.p_pinned) s.pinned = true;
if (r.p_color != null) s.color = r.p_color as string;
+ if (r.agent_last_reply != null && Number(r.agent_last_reply) > Number(r.p_read_at ?? 0) && isWebThread(s.threadRef))
+ s.unread = true;
if (r.user_last_activity != null) s.lastActivityAt = Number(r.user_last_activity);
if (r.has_entries != null) s.hasEntries = Boolean(r.has_entries);
return s;
@@ -249,6 +251,9 @@ export function createPostgresSessionStore(connectionString: string, opts: Store
.join(" UNION ALL ");
const participantSessionsSql = (extraWhere: string): string =>
`SELECT s.*, p.title AS p_title, p.archived AS p_archived, p.pinned AS p_pinned, p.color AS p_color,
+ p.read_at AS p_read_at,
+ (SELECT MAX(e.created_at) FROM session_entries e
+ WHERE e.session_id = s.id AND e.type IN ('assistant', 'delivery')) AS agent_last_reply,
COALESCE((SELECT MAX(e.created_at) FROM session_entries e
WHERE e.session_id = s.id AND e.type = 'user'), s.created_at) AS user_last_activity,
EXISTS (${participantPresenceSql}) AS has_entries
@@ -812,6 +817,21 @@ export function createPostgresSessionStore(connectionString: string, opts: Store
ON sessions((COALESCE(last_activity, created_at)) DESC, id DESC)`,
],
},
+ {
+ id: "sessions/store/0026-participant-read-at",
+ statements: [
+ `ALTER TABLE participants ADD COLUMN IF NOT EXISTS read_at BIGINT`,
+ `UPDATE participants SET read_at = (EXTRACT(EPOCH FROM clock_timestamp()) * 1000)::bigint WHERE read_at IS NULL`,
+ `ALTER TABLE sessions DROP COLUMN IF EXISTS status`,
+ ],
+ },
+ {
+ id: "sessions/store/0027-agent-reply-index",
+ statements: [
+ `CREATE INDEX CONCURRENTLY IF NOT EXISTS session_entries_agent_reply
+ ON session_entries(session_id, created_at DESC) WHERE type IN ('assistant', 'delivery')`,
+ ],
+ },
],
[
{
@@ -998,13 +1018,6 @@ export function createPostgresSessionStore(connectionString: string, opts: Store
await q("UPDATE sessions SET title = $2 WHERE id = $1", [sessionId, title]);
},
- async updateStatus(sessionId, status): Promise<void> {
- await q("UPDATE sessions SET status = $2::jsonb WHERE id = $1", [
- sessionId,
- status ? JSON.stringify(status) : null,
- ]);
- },
-
async updateForkProvenance(sessionId, provenance): Promise<void> {
await q(
"UPDATE sessions SET forked_from_session_id = $2, forked_from_title = $3, fork_boundary_seq = $4 WHERE id = $1",
@@ -1567,6 +1580,13 @@ export function createPostgresSessionStore(connectionString: string, opts: Store
patch.color,
]);
}
+ if (patch.readAt !== undefined) {
+ await q("UPDATE participants SET read_at = $3 WHERE session_id = $1 AND principal_id = $2", [
+ sessionId,
+ principalId,
+ patch.readAt,
+ ]);
+ }
},
async addPin(sessionId, pin: NewSessionPin, maxPins?: number): Promise<SessionPin | null> {
diff --git a/src/sessions/session-status.ts b/src/sessions/session-status.ts
deleted file mode 100644
index 0d21486b2..000000000
--- a/src/sessions/session-status.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { SessionStatus } from "../types.ts";
-
-const emojiPattern = new RegExp("^\\p{RGI_Emoji}$", "v");
-
-export function isSessionStatus(value: unknown): value is SessionStatus | null {
- if (value === null) return true;
- if (typeof value !== "object" || Array.isArray(value)) return false;
- const status = value as Partial<SessionStatus>;
- return (
- typeof status.emoji === "string" &&
- emojiPattern.test(status.emoji) &&
- typeof status.text === "string" &&
- status.text.isWellFormed() &&
- status.text.trim().length > 0 &&
- status.text.length <= 200 &&
- !/[\u0000-\u001f\u007f]/u.test(status.text)
- );
-}
diff --git a/src/sessions/session-store.ts b/src/sessions/session-store.ts
index d9f02bae3..aebe09e38 100644
--- a/src/sessions/session-store.ts
+++ b/src/sessions/session-store.ts
@@ -133,6 +133,7 @@ interface ParticipantViewPatch {
archived?: boolean;
pinned?: boolean;
color?: string | null;
+ readAt?: number;
}
export interface NewSessionPin {
@@ -149,6 +150,8 @@ export interface SessionPin extends NewSessionPin {
type TapeKind = "message" | "context_event" | "annotation";
+export const isWebThread = (threadRef: string): boolean => threadRef.startsWith("web:");
+
export const TAPE_RENDER_VERSION = 1;
export interface TapeCheckpointEntry {
@@ -716,7 +719,6 @@ export interface SessionStore {
setParentSession(sessionId: string, parentSessionId: string | null): Promise<void>;
setSpawnMeta(sessionId: string, meta: SpawnMeta): Promise<void>;
childrenOf(parentSessionId: string): Promise<Session[]>;
- updateStatus(sessionId: string, status: Session["status"]): Promise<void>;
updateForkProvenance(
sessionId: string,
provenance: { forkedFrom: { sessionId: string; title?: string | null }; forkBoundarySeq: number },
diff --git a/src/types.ts b/src/types.ts
index 2962a85c3..1c8f9d19d 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -90,11 +90,6 @@ export interface SpawnMeta {
fastMode?: boolean;
}
-export interface SessionStatus {
- emoji: string;
- text: string;
-}
-
export interface Session {
id: string;
type: SessionType;
@@ -107,7 +102,7 @@ export interface Session {
archived?: boolean;
pinned?: boolean;
color?: string;
- status?: SessionStatus | null;
+ unread?: boolean;
forkedFrom?: { sessionId: string; title?: string | null };
forkBoundarySeq?: number;
parentSessionId?: string;
diff --git a/test/agent-api-discovery.test.ts b/test/agent-api-discovery.test.ts
index 4b368281d..83b349172 100644
--- a/test/agent-api-discovery.test.ts
+++ b/test/agent-api-discovery.test.ts
@@ -273,24 +273,3 @@ test("disabled swarms are absent from discovery and reject direct API calls", as
await close();
}
});
-
-test("conversation status is advertised on web turns and omitted on Slack turns", async () => {
- const s = await start();
- try {
- const update = (body: any) =>
- body.endpoints.filter((e: any) => e.path === "/v1/conversations/:id" && e.method === "POST");
- const cap = (surface: string) =>
- mintCapabilityToken(
- { actorId: "U1", scopeId: scopeId("personal", "U1"), exp: Date.now() + CAPABILITY_TTL_MS, surface },
- SECRET,
- );
- const web = update((await listApis(s.base, await cap("web"))).body);
- assert.equal(web.length, 1);
- assert.match(web[0].summary, /sidebar status/);
- const slack = update((await listApis(s.base, await cap("slack"))).body);
- assert.equal(slack.length, 1);
- assert.doesNotMatch(JSON.stringify(slack), /status/i);
- } finally {
- await s.close();
- }
-});
diff --git a/test/agent-conversations-route.test.ts b/test/agent-conversations-route.test.ts
index fff6dbee8..ce975c399 100644
--- a/test/agent-conversations-route.test.ts
+++ b/test/agent-conversations-route.test.ts
@@ -5,7 +5,7 @@ import type { AddressInfo } from "node:net";
import type { Server } from "node:http";
import { buildApp, type BuiltApp } from "../src/wiring.ts";
import { createServer } from "../src/api/server.ts";
-import { scopeId, type TurnRequest, type SessionStatus } from "../src/types.ts";
+import { scopeId, type TurnRequest } from "../src/types.ts";
import { startSession } from "../src/api/start-session.ts";
import { mintCapabilityToken, CAPABILITY_TTL_MS, CONTROL_PLANE_AUD } from "../src/auth/capability-token.ts";
import { testConfig } from "./support/test-config.ts";
@@ -57,66 +57,15 @@ describe("agent conversations self-API", async () => {
await new Promise<void>((resolve) => server.close(() => resolve()));
});
- it("sets, replaces, lists and clears a shared session status", async () => {
- const token = await capFor("U1");
- await built.sessions.addParticipant(mineId, "U3");
- for (const status of [{ emoji: "βœ…", text: "PR merged" }, { emoji: "πŸš€", text: "Live in production" }, null]) {
- const res = await post(`/v1/conversations/${mineId}`, { status }, token);
- assert.equal(res.status, 200);
- assert.deepEqual(
- ((await res.json()) as { conversation: { status: SessionStatus | null } }).conversation.status,
- status,
- );
- assert.deepEqual((await built.app.getSessionForViewer(mineId, "U3"))?.session.status ?? null, status);
- const list = await get("/v1/conversations", token);
- assert.deepEqual(
- (
- (await list.json()) as { conversations: Array<{ id: string; status: SessionStatus | null }> }
- ).conversations.find((s) => s.id === mineId)?.status ?? null,
- status,
- );
- }
- });
-
- it("rejects malformed status and unauthorized status updates", async () => {
- const token = await capFor("U1");
- for (const status of [
- {},
- { emoji: "abc", text: "Merged" },
- { emoji: "βœ…πŸš€", text: "Merged" },
- { emoji: "βœ…", text: " " },
- { emoji: "βœ…", text: "x".repeat(201) },
- { emoji: "βœ…", text: "a\u0000b" },
- "merged",
- ]) {
- assert.equal((await post(`/v1/conversations/${mineId}`, { status }, token)).status, 400);
- }
- assert.equal(
- (await post(`/v1/conversations/${theirsId}`, { status: { emoji: "βœ…", text: "Merged" } }, token)).status,
- 404,
- );
- assert.equal((await post(`/v1/conversations/${mineId}`, { status: null })).status, 401);
- });
-
- it("refuses conversation status from Slack turns while other updates still apply", async () => {
- const slack = await mintCapabilityToken(
- {
- actorId: "U1",
- scopeId: scopeId("personal", "U1"),
- aud: CONTROL_PLANE_AUD,
- exp: Date.now() + CAPABILITY_TTL_MS,
- liveActor: true,
- surface: "slack",
- },
- SECRET,
- );
- const before = (await built.app.getSessionForViewer(mineId, "U1"))?.session.status ?? null;
- const refused = await post(`/v1/conversations/${mineId}`, { status: { emoji: "πŸ‘", text: "Cleared" } }, slack);
- assert.equal(refused.status, 403);
- assert.deepEqual((await built.app.getSessionForViewer(mineId, "U1"))?.session.status ?? null, before);
- const renamed = await post(`/v1/conversations/${mineId}`, { title: "Launch plan" }, slack);
- assert.equal(renamed.status, 200);
- assert.equal(((await renamed.json()) as { conversation: { title: string } }).conversation.title, "Launch plan");
+ it("web conversations go unread on an agent reply until read; other threads never do", async () => {
+ const unread = async (id: string) => (await built.app.listSessions("U1")).find((s) => s.id === id)?.unread === true;
+ assert.equal(await unread(mineId), true);
+ await built.app.updateSession(mineId, "U1", { readAt: Date.now() });
+ assert.equal(await unread(mineId), false);
+ await built.app.updateSession(mineId, "U1", { readAt: 0 });
+ assert.equal(await unread(mineId), true);
+ const slackId = (await built.app.turn(dm("U1", "from slack", "dm:D1")))!.sessionId!;
+ assert.equal(await unread(slackId), false);
});
it("new sessions start clean with only the seed text", async () => {
diff --git a/test/agent-transcript-memory-boundary.test.ts b/test/agent-transcript-memory-boundary.test.ts
index 142923281..91f2eea36 100644
--- a/test/agent-transcript-memory-boundary.test.ts
+++ b/test/agent-transcript-memory-boundary.test.ts
@@ -208,7 +208,6 @@ test("agent transcript retains viewer-visible history across memory checkpoints"
const old = await f.append("assistant", { text: "PRIVATE_SENTINEL" });
await f.built.sessions.addPin(f.session.id, { addedBy: "alice", text: "PRIVATE_SENTINEL" });
await f.built.sessions.updateTitle(f.session.id, "PRIVATE_SENTINEL");
- await f.built.sessions.updateStatus(f.session.id, { emoji: "βœ…", text: "PRIVATE_SENTINEL" });
f.setAudience([{ id: "alice", type: "internal" }]);
await f.checkpoint(old.seq);
await f.append("user", { text: "new question" });
@@ -256,17 +255,15 @@ test("adding an authorized fact preserves an otherwise compatible checkpoint", a
}
});
-test("agent list and patch responses include viewer-visible titles and statuses", async () => {
+test("agent list and patch responses include viewer-visible titles", async () => {
const f = await fixture();
try {
await f.built.sessions.updateTitle(f.session.id, "PRIVATE_TITLE");
- await f.built.sessions.updateStatus(f.session.id, { emoji: "βœ…", text: "PRIVATE_STATUS" });
const listed = await f.list();
assert.equal(listed.status, 200);
const listing = await listed.text();
assert.match(listing, new RegExp(f.session.id));
assert.match(listing, /PRIVATE_TITLE/);
- assert.match(listing, /PRIVATE_STATUS/);
const patch = await f.post("", { archived: true });
assert.equal(patch.status, 200);
assert.match(await patch.text(), /PRIVATE_TITLE/);
@@ -274,10 +271,6 @@ test("agent list and patch responses include viewer-visible titles and statuses"
assert.equal(renamed.status, 200);
const renamedBody = await renamed.text();
assert.match(renamedBody, /safe title/);
- assert.match(renamedBody, /PRIVATE_STATUS/);
- const cleared = await f.post("", { status: null });
- assert.equal(cleared.status, 200);
- assert.equal(((await cleared.json()) as { conversation: { status: null } }).conversation.status, null);
} finally {
await f.close();
}
diff --git a/test/postgres-store.test.ts b/test/postgres-store.test.ts
index bca359e6c..b4894125e 100644
--- a/test/postgres-store.test.ts
+++ b/test/postgres-store.test.ts
@@ -3403,20 +3403,6 @@ test("pg child parentage and spawn metadata survive reopening", { skip }, async
assert.equal((await reopened.get(child.id))?.parentSessionId, undefined);
});
-test("pg session status survives restart, is shared, and clears", { skip }, async () => {
- const first = createPostgresSessionStore(URL!);
- const session = await first.getOrCreateByThread("session-status", "dm", scopeId("personal", "U1"));
- await first.addParticipant(session.id, "U1");
- await first.addParticipant(session.id, "U2");
- const status = { emoji: "πŸš€", text: "Live in production" };
- await first.updateStatus(session.id, status);
- const restarted = createPostgresSessionStore(URL!);
- assert.deepEqual((await restarted.get(session.id))?.status, status);
- assert.deepEqual((await restarted.getForParticipant(session.id, "U2"))?.status, status);
- await restarted.updateStatus(session.id, null);
- assert.equal((await first.get(session.id))?.status ?? null, null);
-});
-
test(
"pg legacy completion wakeups remain discoverable after return and restart until withdrawn",
{ skip },
diff --git a/test/session-status.test.ts b/test/session-status.test.ts
deleted file mode 100644
index 02aefd55d..000000000
--- a/test/session-status.test.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import "./support/auto-fake-sprites.ts";
-import { test } from "node:test";
-import assert from "node:assert/strict";
-import { isSessionStatus } from "../src/sessions/session-status.ts";
-import { buildApp } from "../src/wiring.ts";
-import { testConfig } from "./support/test-config.ts";
-import type { SessionStateEvent } from "../src/runs/session-state-bus.ts";
-
-test("status accepts compound emoji and rejects multiple emoji, shortcodes, and empty text", () => {
- for (const emoji of ["βœ…", "πŸš€", "πŸ‘©πŸ½β€πŸ’»", "πŸ‡ΊπŸ‡Έ", "1️⃣"]) assert.ok(isSessionStatus({ emoji, text: "Ready" }));
- for (const emoji of ["", "a", ":rocket:", "πŸš€βœ…"]) assert.equal(isSessionStatus({ emoji, text: "Ready" }), false);
- for (const text of ["Ready\ud800", "Ready\udc00"]) assert.equal(isSessionStatus({ emoji: "βœ…", text }), false);
- assert.equal(isSessionStatus(undefined), false);
- assert.ok(isSessionStatus(null));
-});
-
-test("status changes notify viewers without changing run state; former participants cannot write", async () => {
- const built = buildApp(testConfig({}));
- const turn = await built.app.turn({
- surface: "test",
- actor: { externalId: "U1" },
- conversation: { kind: "dm", threadRef: "status-notify" },
- text: "hello",
- });
- const id = turn.sessionId!;
- await built.sessions.addParticipant(id, "U2");
- const events: SessionStateEvent[] = [];
- const unsub = built.app.subscribeSessionStates((e) => events.push(e));
- const status = { emoji: "βœ…", text: "PR merged" };
- assert.deepEqual((await built.app.updateSession(id, "U1", { status }))?.status, status);
- await new Promise((resolve) => setImmediate(resolve));
- assert.equal(events.length, 1);
- assert.equal(events[0]?.state, "metadata");
- assert.ok(events[0]?.participants?.includes("U2"));
- await built.sessions.removeParticipant(id, "U2");
- assert.equal(await built.app.updateSession(id, "U2", { status: null }), null);
- assert.deepEqual((await built.sessions.get(id))?.status, status);
- unsub();
-});
diff --git a/test/session-view-patch.test.ts b/test/session-view-patch.test.ts
index 49d3ef76c..99adda675 100644
--- a/test/session-view-patch.test.ts
+++ b/test/session-view-patch.test.ts
@@ -94,18 +94,17 @@ test("POST /v1/sessions/:id rejects malformed colors and non-boolean pins", asyn
}
});
-test("surface session route sets and clears status, rejecting malformed input", async () => {
+test("surface session route marks a conversation unread and read", async () => {
const srv = start();
try {
- const id = await newSession(srv.base, "web:U1:status");
- const status = { emoji: "πŸš€", text: "Live in production" };
- const set = await patch(srv.base, id, { principalId: "U1", status });
- assert.equal(set.status, 200);
- assert.deepEqual(set.session?.status, status);
- assert.equal((await patch(srv.base, id, { principalId: "U1", status: {} })).status, 400);
- const cleared = await patch(srv.base, id, { principalId: "U1", status: null });
- assert.equal(cleared.status, 200);
- assert.equal(cleared.session?.status ?? null, null);
+ const id = await newSession(srv.base, "web:U1:unread");
+ const unread = await patch(srv.base, id, { principalId: "U1", unread: true });
+ assert.equal(unread.status, 200);
+ assert.equal(unread.session?.unread, true);
+ const read = await patch(srv.base, id, { principalId: "U1", unread: false });
+ assert.equal(read.status, 200);
+ assert.equal(read.session?.unread ?? false, false);
+ assert.equal((await patch(srv.base, id, { principalId: "U1", unread: "yes" })).status, 400);
} finally {
await srv.close();
}