Specialists ask questions, request approvals and the computer screen in their own threads, and the user only finds out by opening each thread. With the main conversation as the single entry point, those requests have to reach the user there, with the specialist as the visible sender. - inbox.list returns, for the current space and the user's own bots, pending asks and approvals (bot messages with a pending ask block whose run waits for input), takeover requests, and unread specialist threads. Asks already in the main conversation are left out; takeovers stay because their controls live in the bot's own thread. Each item carries the bot, the thread target, run and message ids, and the ask block for asks and approvals. - The main conversation shows the items above the composer. Asks and approvals are answered in place through threads.answer with the source thread target; takeovers and unread threads open the bot's thread. The list refreshes when the bots' status, unread state or newest message changes, every 15 seconds, and after an answer. - The inbox shrinks and scrolls so it never pushes the composer out of view. The transcript now clips its scroller: with no room left in the column, the scroller's padding used to spill over whatever sat below it. - The ask block schema is extracted from MessageBlock so the inbox contract reuses it, and AskCard accepts a className. Tests: unit tests for the item builder and the component, a Postgres suite for the query (added to the harness list), inbox cases in the authorization suite, and an E2E spec in which a specialist asks in its own thread and the user answers from the main conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
25 lines
801 B
TypeScript
25 lines
801 B
TypeScript
import type { Bot, InboxItem } from "@rakazo/contracts";
|
|
|
|
/** One item per pending ask message, waiting takeover run, or unread bot thread. */
|
|
export function inboxItemKey(item: InboxItem): string {
|
|
switch (item.kind) {
|
|
case "ask":
|
|
case "approval":
|
|
return `ask:${item.messageId}`;
|
|
case "takeover":
|
|
return `takeover:${item.runId}`;
|
|
case "unread":
|
|
return `unread:${item.bot.id}`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Changes when a bot's run status, unread flag or newest message changes, which is when the
|
|
* inbox may have changed. The shell already keeps these fresh.
|
|
*/
|
|
export function inboxRefreshSignal(
|
|
bots: readonly Pick<Bot, "id" | "status" | "unread" | "preview">[],
|
|
): string {
|
|
return bots.map((bot) => `${bot.id}:${bot.status}:${bot.unread}:${bot.preview}`).join("\n");
|
|
}
|