Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions api/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,21 @@ components:
- string
- "null"
description: The Bot that wrote the newest message, or null when a person did.
lastTurnInitiator:
type:
- string
- "null"
x-extensible-enum:
- person
- routine
- task
description: >-
Who started the turn the newest message belongs to: the person
(person), a routine, check-in or goal (routine), or a task a Bot
handed the work to (task), as the conversation's lastTurnInitiator
in the list says it. Null when the server can't say. Absent from a
server older than this, and then the client knows nothing of who
started it.
firstLine:
type: string
description: A Bot's reply, its first line as plain text. Only on a Bot's message.
Expand Down
9 changes: 9 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34646,6 +34646,15 @@ components:
- string
- 'null'
description: The Bot that said it, or null when a person did.
lastTurnInitiator:
type:
- string
- 'null'
x-extensible-enum:
- person
- routine
- task
description: 'Who started the turn the last thing said in it belongs to: the person (person), a routine, check-in or goal (routine), or a task a Bot handed the work to (task). With a Bot''s message last, routine means a routine spoke last and nobody has written since. Null when nothing has been said, or when the last message is older than the server''s keeping it. Absent from a server that predates it. An app reads null, absence and a value it doesn''t know alike: as nothing known about who started it.'
createdAt:
type: string
format: date-time
Expand Down
12 changes: 12 additions & 0 deletions api/openapi/conversations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,18 @@ components:
- string
- 'null'
description: The Bot that said it, or null when a person did.
lastTurnInitiator:
type: [string, 'null']
x-extensible-enum: [person, routine, task]
description: >-
Who started the turn the last thing said in it belongs to: the
person (person), a routine, check-in or goal (routine), or a task a
Bot handed the work to (task). With a Bot's message last, routine
means a routine spoke last and nobody has written since. Null when
nothing has been said, or when the last message is older than the
server's keeping it. Absent from a server that predates it. An app
reads null, absence and a value it doesn't know alike: as nothing
known about who started it.
createdAt:
type: string
format: date-time
Expand Down
20 changes: 18 additions & 2 deletions app/src/components/agents/bot-orb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ export function BotOrbArt({
*/
export type BotOrbState = "idle" | "working" | "waiting";

/**
* What started what the orb's Bot said last, when that is worth showing, drawn inside the orb
* (styles.css, `.bot-orb[data-started-by]`) beside whatever its state draws around it.
*
* - `routine`: a routine (a schedule, a check-in, a goal) spoke last, and nobody has written since.
* A small clock inside the orb: a pale, soft dial and one slim hand at one o'clock, a shade deeper
* than the orb, so a routine's conversation reads apart from the person's own.
*
* A trigger's run can be one more name here, or wear the same clock.
*/
export type BotOrbStartedBy = "routine";

/**
* The one color an orb reads as from a step back: halfway between its ground's two colors, the
* sweep from the top left to the foot that the rest of the drawing lights. What a state draws in the
Expand All @@ -284,26 +296,30 @@ export function orbColor({ silk: { from, to } }: OrbLook): string {
* color. One drawing at every size, folds and all, so a Bot is the same in the sidebar, at the top
* of its page and at the top of a conversation.
*
* Its `state` is drawn around it (`BotOrbState`). The orb names the Bot alone: what a state means
* in words is the caller's to say, where it says the rest. Nothing moves under reduced motion.
* Its `state` is drawn around it (`BotOrbState`), and what started what it said last inside it
* (`startedBy`). The orb names the Bot alone: what either means in words is the caller's to say,
* where it says the rest. Nothing moves under reduced motion.
*/
export function BotOrb({
seed,
name,
size = 32,
state = "idle",
startedBy,
}: {
seed: string;
name: string;
size?: number;
state?: BotOrbState;
startedBy?: BotOrbStartedBy;
}) {
const look = orbLook(seed);
return (
<span
aria-label={name}
className="bot-orb inline-block shrink-0 rounded-full"
data-palette={look.name}
data-started-by={startedBy}
data-state={state}
data-variant={state === "working" ? "live" : "static"}
role="img"
Expand Down
9 changes: 9 additions & 0 deletions app/src/components/app-sidebar/channel-item-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import type { MessageListEmphasis } from "@/lib/settings/message-list";
* age line up before it. The pin used to come after the dot, and on a pinned row pushed it out of
* the column. A row whose orb says it keeps no place for a dot.
*
* A conversation a routine spoke in last, with nothing written since (`routine`), has a small clock
* drawn inside its Bot's orb (`BotOrb`'s `startedBy`), so a routine's conversations read apart from
* the person's own at a glance. Like the arcs it needs a lone orb, and draws nothing elsewhere.
*
* While its Bot works, the row says what the Bot is doing at the right, in place of the age and in
* the age's muted style: `status`, or "Working" while `busy`. No line is added, so a row keeps its
* height when a Bot starts or stops and the rows under it don't move.
Expand All @@ -37,6 +41,7 @@ export function ChannelItemContent({
busy = false,
status,
unread = false,
routine = false,
pinned = false,
revealing = false,
view = "detailed",
Expand All @@ -52,6 +57,8 @@ export function ChannelItemContent({
/** What the Bot is doing, said in place of the age. "Working" while `busy` if not given. */
status?: string;
unread?: boolean;
/** Whether a routine spoke last and nobody has written since: a clock in the orb. */
routine?: boolean;
pinned?: boolean;
revealing?: boolean;
view?: ConversationView;
Expand Down Expand Up @@ -118,6 +125,7 @@ export function ChannelItemContent({
<div className="shrink-0">
<ChannelAvatar
participantIds={participantIds}
routine={routine}
size={20}
typing={busy}
waiting={unread}
Expand Down Expand Up @@ -153,6 +161,7 @@ export function ChannelItemContent({
<div className="shrink-0">
<ChannelAvatar
participantIds={participantIds}
routine={routine}
size={32}
typing={busy}
waiting={unread}
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/app-sidebar/channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const Channel = memo(function Channel({
pinned,
canRename,
unread,
routine = false,
busy,
status,
emphasis,
Expand All @@ -60,6 +61,8 @@ export const Channel = memo(function Channel({
/** Whether this person started the conversation, and so may rename it. The server's answer. */
canRename: boolean;
unread: boolean;
/** Whether a routine spoke last and nobody has written since (`routineSpokeLast`). */
routine?: boolean;
busy: boolean;
/** What its Bot is doing while it works, said in place of its age. See `ChannelItemContent`. */
status?: string;
Expand Down Expand Up @@ -131,6 +134,7 @@ export const Channel = memo(function Channel({
busy={busy}
status={status}
unread={unread}
routine={routine}
pinned={pinned}
revealing={revealed.typing}
view={view}
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/app-sidebar/conversations-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
channelSearchInfiniteQueryOptions,
isChannelSearchable,
normalizeChannelSearch,
routineSpokeLast,
} from "@/lib/channels/queries";
import { loadFailure } from "@/lib/load-failure";
import { EASE_OUT, ENTRANCE_SECONDS } from "@/lib/motion";
Expand Down Expand Up @@ -236,6 +237,7 @@ function ChannelRow({
pinned={channel.pinned}
canRename={channel.canRename ?? false}
unread={unread}
routine={routineSpokeLast(channel)}
// A turn running, work the conversation waits on (a hop, a routine), or a task it handed out.
busy={isWorking(channel, delegating)}
status={workStatus(channel, delegating) ?? undefined}
Expand Down
15 changes: 13 additions & 2 deletions app/src/components/channels/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { useQuery } from "@tanstack/react-query";
import Avatar from "boring-avatars";
import { memo, type ReactNode } from "react";
import { useBotLook } from "@/components/agents/bot-look";
import { BotOrb, type BotOrbState } from "@/components/agents/bot-orb";
import {
BotOrb,
type BotOrbStartedBy,
type BotOrbState,
} from "@/components/agents/bot-orb";
import { agentListQueryOptions } from "@/lib/agents/queries";
import { cn } from "@/lib/utils";

Expand All @@ -23,18 +27,21 @@ import { cn } from "@/lib/utils";
*
* `waiting` puts the waiting arcs on a lone Bot's orb (`BotOrb`'s state), for a conversation with
* something new in it; where the avatar is not one orb (`useOneOrb`) it draws nothing, and the row
* says it another way.
* says it another way. `routine` draws the routine's clock inside that orb (`BotOrb`'s
* `startedBy`), for a conversation a routine spoke in last; elsewhere it draws nothing.
*/
export const ChannelAvatar = memo(function ChannelAvatar({
participantIds,
size = 32,
typing = false,
waiting = false,
routine = false,
}: {
participantIds: string[];
size?: number;
typing?: boolean;
waiting?: boolean;
routine?: boolean;
}) {
const orbs = useBotLook() === "orb";
const face = orbs ? orbFace : boringFace;
Expand All @@ -44,6 +51,7 @@ export const ChannelAvatar = memo(function ChannelAvatar({
<OrbFace
id={participantIds[0]}
size={size}
startedBy={routine ? "routine" : undefined}
state={waiting ? "waiting" : "idle"}
/>
) : (
Expand Down Expand Up @@ -124,10 +132,12 @@ function OrbFace({
id,
size,
state = "idle",
startedBy,
}: {
id: string;
size: number;
state?: BotOrbState;
startedBy?: BotOrbStartedBy;
}) {
const { data: bot } = useQuery({
...agentListQueryOptions(),
Expand All @@ -139,6 +149,7 @@ function OrbFace({
name={bot?.name ?? ""}
seed={bot?.avatarSeed ?? id}
size={size}
startedBy={startedBy}
state={state}
/>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ export const ListConversationsResponse = zod.object({
.string()
.nullable()
.describe("The Bot that said it, or null when a person did."),
lastTurnInitiator: zod
.string()
.nullish()
.describe(
"Who started the turn the last thing said in it belongs to: the person (person), a routine, check-in or goal (routine), or a task a Bot handed the work to (task). With a Bot's message last, routine means a routine spoke last and nobody has written since. Null when nothing has been said, or when the last message is older than the server's keeping it. Absent from a server that predates it. An app reads null, absence and a value it doesn't know alike: as nothing known about who started it.",
),
createdAt: zod.iso
.datetime({ offset: true })
.describe("When it was started."),
Expand Down
5 changes: 5 additions & 0 deletions app/src/lib/api/generated/model/conversationSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export interface ConversationSummary {
* @nullable
*/
lastMessageBotId: string | null;
/**
* Who started the turn the last thing said in it belongs to: the person (person), a routine, check-in or goal (routine), or a task a Bot handed the work to (task). With a Bot's message last, routine means a routine spoke last and nobody has written since. Null when nothing has been said, or when the last message is older than the server's keeping it. Absent from a server that predates it. An app reads null, absence and a value it doesn't know alike: as nothing known about who started it.
* @nullable
*/
lastTurnInitiator?: string | null;
/** When it was started. */
createdAt: string;
/** Whether the caller pinned it. */
Expand Down
21 changes: 21 additions & 0 deletions app/src/lib/channels/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ export type ChannelSummary = AgentChannel & {
opening?: string | null;
lastMessage: string | null;
lastMessageAgentId: string | null;
/**
* Who started the turn the last message belongs to: `person`, `routine` (a routine, check-in or
* goal) or `task`, or another the server adds later. Null or absent when the server can't say, or
* predates saying it (`routineSpokeLast`).
*/
lastTurnInitiator?: string | null;
/** ISO-8601. Ordering falls back to this, so a channel just created sorts to the top. */
createdAt: string;
/** Whether this member pinned the channel. Pinned channels sort first in the roster. */
Expand Down Expand Up @@ -346,6 +352,21 @@ export function listedChannel(
.find((one) => one.id === channelId);
}

/**
* Whether a routine spoke last in a conversation and nobody has written since: the last message is a
* Bot's, in a turn a routine started. A person's message starts a turn of their own, so it ends
* this. Read only from what the server says; one that says nothing of who started the turn shows
* none.
*/
export function routineSpokeLast(
channel: Pick<ChannelSummary, "lastTurnInitiator" | "lastMessageAgentId">,
): boolean {
return (
channel.lastTurnInitiator === "routine" &&
channel.lastMessageAgentId !== null
);
}

/**
* A conversation as the API answers it, in the names the app's screens and its socket events use:
* the API calls a conversation's Bots `botIds`.
Expand Down
16 changes: 15 additions & 1 deletion app/src/lib/channels/use-channel-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export type ChannelActivityEvent = {
lastMessage: string | null;
lastMessageAt: string | null;
lastMessageAgentId: string | null;
/**
* Who started the turn the newest message belongs to, as the list's `lastTurnInitiator`. Absent
* from a server older than this, and then the row knows nothing of it (`applyChannelEvent`).
*/
lastTurnInitiator?: string | null;
/**
* A Bot's reply, its first line as plain text, for the notice a reply raises while OpenBot is out
* of sight. `lastMessage` runs every line into one. Only on a Bot's message, and absent from a
Expand Down Expand Up @@ -294,7 +299,16 @@ export function applyChannelEvent(

// Preserve object identity for unchanged rows so memoized rows do not re-render.
const next = page.channels.slice();
next[index] = { ...previous, ...activity };
/*
* Who started the turn goes with the message it is about. An event that says nothing of it, from
* a server older than `lastTurnInitiator`, leaves the row saying nothing either: the old message's
* would be wrong for the new one.
*/
const { lastTurnInitiator: _, ...unsaid } = previous;
next[index] = {
...(activity.lastTurnInitiator === undefined ? unsaid : previous),
...activity,
};
next.sort(byRecency);

// An event that changes nothing visible, a duplicate, or a report the server ignored as stale,
Expand Down
Loading
Loading