Skip to content

The agent that grows with you

feat(desktop): let a plugin title an empty chat it owns

Brooklyn Nicholson45176219a23e
diff --git a/apps/desktop/src/components/assistant-ui/chat-empty-slot.tsx b/apps/desktop/src/components/assistant-ui/chat-empty-slot.tsx
new file mode 100644
index 00000000000..3009f2a9801
--- /dev/null
+++ b/apps/desktop/src/components/assistant-ui/chat-empty-slot.tsx
@@ -0,0 +1,36 @@
+import type { FC } from 'react'
+import { useMemo } from 'react'
+
+import { useContributions } from '@/contrib'
+import { ContribBoundary, ContribRender } from '@/contrib/react/boundary'
+import { CHAT_EMPTY_AREA, type ChatEmptyContribution } from '@/lib/chat-empty'
+
+/**
+ * The empty transcript's contributed slot. Mounts the first registration and
+ * lets it decide — it renders the session's empty state, or nothing at all if
+ * the session isn't one it owns.
+ *
+ * Deliberately a mount rather than a claim the transcript resolves up front:
+ * whether a session has an empty state depends on data the plugin loads on its
+ * own clock (a bot chat's roster lands after the transcript), and only a
+ * mounted component can subscribe and appear when it arrives.
+ */
+export const ChatEmptySlot: FC<{ sessionId: string }> = ({ sessionId }) => {
+ const contributions = useContributions(CHAT_EMPTY_AREA)
+ const match = contributions[0]
+ const render = (match?.data as ChatEmptyContribution | undefined)?.render
+
+ // Stable component identity: ContribRender mounts this AS a component, so a
+ // fresh closure per render would remount the empty state on every tick.
+ const renderEmpty = useMemo(() => (render ? () => render({ sessionId }) : null), [render, sessionId])
+
+ if (!match || !renderEmpty) {
+ return null
+ }
+
+ return (
+ <ContribBoundary id={match.id}>
+ <ContribRender render={renderEmpty} />
+ </ContribBoundary>
+ )
+}
diff --git a/apps/desktop/src/components/assistant-ui/thread/index.tsx b/apps/desktop/src/components/assistant-ui/thread/index.tsx
index e67683eb1ff..188f3d1e255 100644
--- a/apps/desktop/src/components/assistant-ui/thread/index.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/index.tsx
@@ -1,5 +1,6 @@
import { createContext, memo, useCallback, useContext, useMemo, useRef, useState } from 'react'
+import { ChatEmptySlot } from '@/components/assistant-ui/chat-empty-slot'
import { AssistantMessage } from '@/components/assistant-ui/thread/assistant-message'
import { ThreadMessageList } from '@/components/assistant-ui/thread/list'
import { BackgroundResumeNotice, CenteredThreadSpinner } from '@/components/assistant-ui/thread/status'
@@ -147,9 +148,15 @@ export const Thread = memo(function Thread({
[hasBranchInNewChat, hasCancel, hasDismissError, hasRestoreToMessage, requestRestoreConfirm]
)
- const emptyPlaceholder = intro ? (
+ // Core's splash belongs to a fresh draft; a session that exists but has
+ // nothing in it yet gets whichever plugin owns it. The slot often renders
+ // nothing, which costs an empty container — harmless, since there is no
+ // content to lay out until the first message swaps this branch out.
+ const emptyBody = intro ? <Intro {...intro} /> : sessionId ? <ChatEmptySlot sessionId={sessionId} /> : null
+
+ const emptyPlaceholder = emptyBody ? (
<div className="flex min-h-0 w-full flex-col items-center justify-center pt-[var(--composer-measured-height)]">
- <Intro {...intro} />
+ {emptyBody}
</div>
) : undefined
diff --git a/apps/desktop/src/components/chat/intro.tsx b/apps/desktop/src/components/chat/intro.tsx
index 6dc365e644f..dd675e32dbc 100644
--- a/apps/desktop/src/components/chat/intro.tsx
+++ b/apps/desktop/src/components/chat/intro.tsx
@@ -1,8 +1,9 @@
-import { type CSSProperties, useState } from 'react'
+import { useState } from 'react'
import { capitalize, normalize } from '@/lib/text'
import introCopyJsonl from './intro-copy.jsonl?raw'
+import { Wordmark } from './wordmark'
type IntroCopy = {
headline: string
@@ -166,16 +167,7 @@ export function Intro({ personality, seed }: IntroProps) {
data-slot="aui_intro"
>
<div className="w-full min-w-0">
- <p
- aria-label={WORDMARK}
- className="fit-text mx-auto mb-1 w-[calc(100%-1rem)] font-['Collapse'] font-bold uppercase leading-[0.9] tracking-[0.08em] text-midground mix-blend-plus-lighter dark:text-foreground/90"
- style={{ '--fit-min': '2.75rem' } as CSSProperties}
- >
- <span>
- <span>{WORDMARK}</span>
- </span>
- <span aria-hidden="true">{WORDMARK}</span>
- </p>
+ <Wordmark className="mb-1" text={WORDMARK} />
<p className="m-0 text-center leading-normal tracking-tight">{copy.body}</p>
</div>
diff --git a/apps/desktop/src/components/chat/wordmark.tsx b/apps/desktop/src/components/chat/wordmark.tsx
new file mode 100644
index 00000000000..6be1230e8c3
--- /dev/null
+++ b/apps/desktop/src/components/chat/wordmark.tsx
@@ -0,0 +1,45 @@
+import type { CSSProperties } from 'react'
+
+import { cn } from '@/lib/utils'
+
+/**
+ * The oversized display lettering of an empty chat — the Collapse face that
+ * writes "HERMES AGENT" across a fresh draft, and a bot's name across its own
+ * empty chat.
+ *
+ * The doubled children are load-bearing, not a typo: `.fit-text` sizes the
+ * visible span from a container query and needs the `aria-hidden` twin laid
+ * out beside it as the width reference. Anything that renders this lettering
+ * comes through here rather than restating that structure.
+ */
+export function Wordmark({
+ className,
+ fitMin = '2.75rem',
+ text,
+ width = 'calc(100% - 1rem)'
+}: {
+ className?: string
+ /** Floor for the fitted font size, as a CSS length. */
+ fitMin?: string
+ text: string
+ /** How much of the column the lettering spans. `.fit-text` sizes to fill
+ * this, so a short word set at full width comes out enormous — a name gets
+ * less room than a twelve-character wordmark. */
+ width?: string
+}) {
+ return (
+ <p
+ aria-label={text}
+ className={cn(
+ 'wordmark fit-text mx-auto text-midground mix-blend-plus-lighter dark:text-foreground/90',
+ className
+ )}
+ style={{ '--fit-min': fitMin, width } as CSSProperties}
+ >
+ <span>
+ <span>{text}</span>
+ </span>
+ <span aria-hidden="true">{text}</span>
+ </p>
+ )
+}
diff --git a/apps/desktop/src/lib/chat-empty.ts b/apps/desktop/src/lib/chat-empty.ts
new file mode 100644
index 00000000000..fca784ef558
--- /dev/null
+++ b/apps/desktop/src/lib/chat-empty.ts
@@ -0,0 +1,33 @@
+import type { ReactNode } from 'react'
+
+/**
+ * CHAT EMPTY STATE — the blank transcript as a contribution area.
+ *
+ * Core owns exactly one empty state: the intro splash, which belongs to a
+ * fresh draft with no session selected. A session that exists but has nothing
+ * in it yet falls outside that — and whoever opened it is the only one who
+ * knows what should stand in the gap. A bot's chat wants the bot's face and
+ * name; core has neither, and should not learn them.
+ *
+ * So the slot is contributed. A plugin claims the sessions it owns by
+ * returning an element for them and `null` for everything else, which is also
+ * how it stands down while the transcript is still hydrating.
+ */
+
+export const CHAT_EMPTY_AREA = 'chat.empty'
+
+/** Props handed to a chat-empty contribution's `render`. */
+export interface ChatEmptyProps {
+ /** The live session whose transcript is empty. */
+ sessionId: string
+}
+
+/** Payload of a `chat.empty` contribution's `data`. */
+export interface ChatEmptyContribution {
+ /** Renders the empty state, or returns `null` to decline the session and
+ * leave the transcript blank. Mounted as a component inside the
+ * contribution error boundary, so it can subscribe to its own stores and
+ * appear once they load — the roster a bot chat needs arrives after the
+ * transcript does. A throw degrades to an inline error, not a dead chat. */
+ render: (props: ChatEmptyProps) => ReactNode
+}
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index 5d0644a21c1..158c87d1cfe 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -1420,6 +1420,9 @@ export { McpTab } from '@/app/skills/mcp-tab'
* Pair it with `anchor` (spawn corner, default `'top-right'`) plus
* `width`/`height`. */
export type { FloatingAnchor } from '@/components/pane-shell/tree/renderer/floating-rect'
+/** The oversized Collapse lettering an empty chat is titled with — core writes
+ * "HERMES AGENT" with it, a `chat.empty` contribution writes its own name. */
+export { Wordmark } from '@/components/chat/wordmark'
export { StatusDot, type StatusTone } from '@/components/status-dot'
export { Badge } from '@/components/ui/badge'
export { Button } from '@/components/ui/button'
@@ -1590,6 +1593,9 @@ export const TITLEBAR_AREAS = { center: 'titleBar.center', left: 'titleBar.left'
* suffix. `relativeTime` is the bidirectional Intl form ("in 14 hr") — use it
* for a scheduled next-run, not for an age. */
export { type AgoLabels, coarseElapsed, fmtDateTime, fmtDayTime, formatAgo, relativeTime } from '@/lib/time'
+/** The blank transcript as a contribution area: claim the sessions you own and
+ * render what stands in the gap. Core's own splash keeps a fresh draft. */
+export { CHAT_EMPTY_AREA, type ChatEmptyContribution, type ChatEmptyProps } from '@/lib/chat-empty'
/** The transcript as a contribution area: register a named `::directive{...}`
* and the model can render your component inline in assistant messages. */
export {
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css
index 054153e0181..951b35443cf 100644
--- a/apps/desktop/src/styles.css
+++ b/apps/desktop/src/styles.css
@@ -1616,6 +1616,19 @@ body.guest-pointer-lock :is(webview, iframe) {
container-type: inline-size;
}
+/* The display lettering an empty chat is titled with. Kept here beside
+ `.fit-text` rather than as utilities on the element: the two always travel
+ together, and the face is the whole point of the treatment — it must not be
+ something a class-merge or a missed scan can quietly drop, leaving the
+ wordmark rendered in body text. */
+.wordmark {
+ font-family: 'Collapse', var(--font-sans);
+ font-weight: 700;
+ line-height: 0.9;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+}
+
.fit-text > [aria-hidden] {
visibility: hidden;
}