Skip to content

The agent that grows with you

fix(desktop): words typed while a card waits show as the user's bubble

alt-glitch2be1ec63a677
diff --git a/apps/desktop/src/components/assistant-ui/connector-tool.tsx b/apps/desktop/src/components/assistant-ui/connector-tool.tsx
index b53e0957431..d46fc7d15d4 100644
--- a/apps/desktop/src/components/assistant-ui/connector-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/connector-tool.tsx
@@ -9,6 +9,7 @@ import { useSessionView } from '@/app/chat/session-view'
import { sessionRoute } from '@/app/routes'
import { ConnectorDirectoryCard } from '@/components/assistant-ui/connector-directory-card'
import { ToolFallback } from '@/components/assistant-ui/tool/fallback'
+import { TypedAnswer } from '@/components/assistant-ui/typed-answer'
import { useConnectionOwner } from '@/components/assistant-ui/use-connection-owner'
import { SCAFFOLD_LABEL_CLASS, ScaffoldRow } from '@/components/chat/scaffold-row'
import { Button } from '@/components/ui/button'
@@ -188,20 +189,11 @@ function ConnectorDirectoryTool({ live, part, request }: ConnectorDirectoryToolP
}
// A timed-out card still names what the user connected before walking away.
-function receiptText(
- copy: ConnectorCopy['directory'],
- answeredInChat: string,
- outcome: ReturnType<typeof recordOf>,
- added: string[]
-): string {
+function receiptText(copy: ConnectorCopy['directory'], outcome: ReturnType<typeof recordOf>, added: string[]): string {
if (added.length > 0) {
return copy.receiptConnected(added.map(connectorTitle).join(', '))
}
- if (connectorText(outcome.said) !== undefined) {
- return answeredInChat
- }
-
return outcome.timed_out === true ? copy.receiptTimedOut : copy.receiptNone
}
@@ -214,21 +206,26 @@ export function ConnectorDirectoryReceipt({ result }: { result: unknown }) {
? outcome.newly_connected.flatMap(name => connectorText(name) ?? [])
: []
- const text = receiptText(copy, t.firstRun.answeredInChat, outcome, added)
+ const said = connectorText(outcome.said)?.trim()
return (
- <div data-conversation-scaffold="" data-slot="connector-directory-receipt">
- <ScaffoldRow>
- {added.map(name => (
- <ConnectorLogo
- className="size-4 rounded-[0.25rem]"
- connector={{ iconUrl: connectorIconUrl(name), name, title: connectorTitle(name) }}
- key={name}
- />
- ))}
- <span className={SCAFFOLD_LABEL_CLASS}>{text}</span>
- </ScaffoldRow>
- </div>
+ <>
+ {added.length > 0 || !said ? (
+ <div data-conversation-scaffold="" data-slot="connector-directory-receipt">
+ <ScaffoldRow>
+ {added.map(name => (
+ <ConnectorLogo
+ className="size-4 rounded-[0.25rem]"
+ connector={{ iconUrl: connectorIconUrl(name), name, title: connectorTitle(name) }}
+ key={name}
+ />
+ ))}
+ <span className={SCAFFOLD_LABEL_CLASS}>{receiptText(copy, outcome, added)}</span>
+ </ScaffoldRow>
+ </div>
+ ) : null}
+ {said ? <TypedAnswer text={said} /> : null}
+ </>
)
}
diff --git a/apps/desktop/src/components/assistant-ui/setup-beat/receipt.tsx b/apps/desktop/src/components/assistant-ui/setup-beat/receipt.tsx
index 24abe732be5..aca1a1a24d1 100644
--- a/apps/desktop/src/components/assistant-ui/setup-beat/receipt.tsx
+++ b/apps/desktop/src/components/assistant-ui/setup-beat/receipt.tsx
@@ -2,6 +2,7 @@
import type { SetupBeat } from '@hermes/shared'
+import { TypedAnswer } from '@/components/assistant-ui/typed-answer'
import { WIDGET_SHELL_CLASS } from '@/components/chat/widget-shell'
import { LAYOUTS_AREA } from '@/components/pane-shell/tree/presets'
import { useContributions } from '@/contrib/react/use-contributions'
@@ -21,7 +22,8 @@ export const SETUP_BEAT_LABEL_CLASS = 'text-[0.6875rem] leading-4 text-(--ui-tex
/** What a settled card shows: the beat's pick, or how the card closed without one. */
export type SetupBeatOutcome =
| { answer: SetupBeatAnswer; beat: SetupBeat; kind: 'answer' }
- | { beat: SetupBeat | null; kind: 'said' | 'skipped_all' | 'timed_out' }
+ | { beat: SetupBeat; kind: 'said'; said: string }
+ | { beat: SetupBeat | null; kind: 'skipped_all' | 'timed_out' }
/** The receipt a setup_beat result calls for; null for a result that showed no card (a value given in
* words, a skip, `done`), which draws nothing. */
@@ -40,8 +42,8 @@ export function setupBeatOutcome(result: SetupBeatToolResult): null | SetupBeatO
return { answer: result.answer, beat, kind: 'answer' }
}
- if (result.said !== undefined) {
- return { beat, kind: 'said' }
+ if (result.said?.trim()) {
+ return { beat, kind: 'said', said: result.said.trim() }
}
return result.timed_out ? { beat, kind: 'timed_out' } : null
@@ -80,13 +82,18 @@ function answerText(beat: SetupBeat, answer: SetupBeatAnswer, names: AnswerNames
}
}
-/** One line where the choice happened: the beat, then what was picked or how the card closed. */
+/** One line where the choice happened: the beat, then what was picked or how the card closed. Words typed
+ * in the composer replace the line with the user's bubble. */
export function SetupBeatReceipt({ outcome }: { outcome: SetupBeatOutcome }) {
+ return outcome.kind === 'said' ? <TypedAnswer text={outcome.said} /> : <ReceiptLine outcome={outcome} />
+}
+
+function ReceiptLine({ outcome }: { outcome: Exclude<SetupBeatOutcome, { kind: 'said' }> }) {
const { t } = useI18n()
const copy = t.firstRun
const presets = useContributions(LAYOUTS_AREA)
- const closed = { said: copy.answeredInChat, skipped_all: copy.skippedAll, timed_out: copy.noAnswer }
+ const closed = { skipped_all: copy.skippedAll, timed_out: copy.noAnswer }
const text =
outcome.kind === 'answer'
diff --git a/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.test.tsx b/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.test.tsx
index 66bae5afbe6..8c9f7e57c64 100644
--- a/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.test.tsx
@@ -1,5 +1,5 @@
import type { ToolCallMessagePartProps } from '@assistant-ui/react'
-import { cleanup, render } from '@testing-library/react'
+import { cleanup, render, screen } from '@testing-library/react'
import { atom } from 'nanostores'
import { afterEach, describe, expect, it } from 'vitest'
@@ -29,6 +29,12 @@ describe('SetupBeatTool', () => {
cleanup()
})
+ it('draws the words typed while the card waited as the user\'s bubble', () => {
+ renderRow({ beat: 'theme', said: 'look around and suggest one for me :D' })
+
+ expect(screen.getByText('look around and suggest one for me :D').closest('[data-slot="typed-answer"]')).not.toBeNull()
+ })
+
it('draws nothing for a refusal meant for the model', () => {
const { container } = renderRow({ error: 'Apply the layout with set_theme; its result settles this beat.' })
diff --git a/apps/desktop/src/components/assistant-ui/theme-picker/theme-tool.tsx b/apps/desktop/src/components/assistant-ui/theme-picker/theme-tool.tsx
index f2b46a6db07..4465e751514 100644
--- a/apps/desktop/src/components/assistant-ui/theme-picker/theme-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/theme-picker/theme-tool.tsx
@@ -19,6 +19,7 @@ import { accentName, resolveAccentPick } from '@/themes/accents'
import type { ThemeMode } from '@/themes/context'
import { ToolFallback } from '../tool/fallback'
+import { TypedAnswer } from '../typed-answer'
import { AccentPickerCard } from './accent-picker-card'
import { setThemeCall } from './args'
@@ -103,6 +104,12 @@ export function ThemeTool(props: ToolCallMessagePartProps) {
if (props.result !== undefined) {
const result = recordOf(props.result)
+ const said = connectorText(result.said)?.trim()
+
+ if (said) {
+ return <TypedAnswer text={said} />
+ }
+
const values = readValues(result.applied ?? result.picked)
if (values || (picker && result.success !== false)) {
diff --git a/apps/desktop/src/components/assistant-ui/typed-answer.tsx b/apps/desktop/src/components/assistant-ui/typed-answer.tsx
new file mode 100644
index 00000000000..aa1efa37e9f
--- /dev/null
+++ b/apps/desktop/src/components/assistant-ui/typed-answer.tsx
@@ -0,0 +1,22 @@
+'use client'
+
+import { USER_BUBBLE_BASE_CLASS } from '@/components/assistant-ui/thread/user-message'
+import { UserMessageText } from '@/components/assistant-ui/thread/user-message-text'
+import { cn } from '@/lib/utils'
+
+/** Words typed in the composer while a card waited, drawn as the user's bubble where the card stood.
+ * They live only in the tool result's `said`: a user row between a tool call and its result breaks the transcript. */
+export function TypedAnswer({ text }: { text: string }) {
+ return (
+ <div className="my-1.5 flex w-full min-w-0 flex-col items-stretch" data-slot="typed-answer">
+ <div
+ className={cn(
+ USER_BUBBLE_BASE_CLASS,
+ 'border-(--ui-stroke-tertiary) text-[length:var(--conversation-text-font-size)] leading-(--dt-line-height) text-foreground/95'
+ )}
+ >
+ <UserMessageText className="wrap-anywhere" text={text} />
+ </div>
+ </div>
+ )
+}
diff --git a/apps/desktop/src/i18n/ar_first_run.ts b/apps/desktop/src/i18n/ar_first_run.ts
index a7cec119182..08bea3419ba 100644
--- a/apps/desktop/src/i18n/ar_first_run.ts
+++ b/apps/desktop/src/i18n/ar_first_run.ts
@@ -17,7 +17,6 @@ export const arFirstRun: FirstRunCopy = {
loading: 'جارٍ التحميل…',
noPlugins: 'لا توجد إضافات لعرضها الآن.',
noneChosen: 'لا شيء',
- answeredInChat: 'تمت الإجابة في المحادثة',
noAnswer: 'لا توجد إجابة',
skippedAll: 'تم تخطي الإعداد',
skip: 'تخطي الإعداد',
diff --git a/apps/desktop/src/i18n/de_first_run.ts b/apps/desktop/src/i18n/de_first_run.ts
index 012778235ea..325a2c7babd 100644
--- a/apps/desktop/src/i18n/de_first_run.ts
+++ b/apps/desktop/src/i18n/de_first_run.ts
@@ -17,7 +17,6 @@ export const deFirstRun: FirstRunCopy = {
loading: 'Wird geladen…',
noPlugins: 'Gerade keine Plugins verfügbar.',
noneChosen: 'Keine',
- answeredInChat: 'Im Chat beantwortet',
noAnswer: 'Keine Antwort',
skippedAll: 'Einrichtung übersprungen',
skip: 'Einrichtung überspringen',
diff --git a/apps/desktop/src/i18n/en_first_run.ts b/apps/desktop/src/i18n/en_first_run.ts
index 97d236b4726..ca69445943b 100644
--- a/apps/desktop/src/i18n/en_first_run.ts
+++ b/apps/desktop/src/i18n/en_first_run.ts
@@ -17,7 +17,6 @@ export const enFirstRun: FirstRunCopy = {
loading: 'Loading…',
noPlugins: 'No plugins to show right now.',
noneChosen: 'None',
- answeredInChat: 'Answered in chat',
noAnswer: 'No answer',
skippedAll: 'Setup skipped',
skip: 'Skip setup',
diff --git a/apps/desktop/src/i18n/es_first_run.ts b/apps/desktop/src/i18n/es_first_run.ts
index 51210dbae0d..6975e8f2ac7 100644
--- a/apps/desktop/src/i18n/es_first_run.ts
+++ b/apps/desktop/src/i18n/es_first_run.ts
@@ -17,7 +17,6 @@ export const esFirstRun: FirstRunCopy = {
loading: 'Cargando…',
noPlugins: 'No hay plugins para mostrar ahora mismo.',
noneChosen: 'Ninguno',
- answeredInChat: 'Respondido en el chat',
noAnswer: 'Sin respuesta',
skippedAll: 'Configuración omitida',
skip: 'Omitir configuración',
diff --git a/apps/desktop/src/i18n/fr_first_run.ts b/apps/desktop/src/i18n/fr_first_run.ts
index ea5ed06fe4d..d06d84e7ef9 100644
--- a/apps/desktop/src/i18n/fr_first_run.ts
+++ b/apps/desktop/src/i18n/fr_first_run.ts
@@ -17,7 +17,6 @@ export const frFirstRun: FirstRunCopy = {
loading: 'Chargement…',
noPlugins: 'Aucun plugin à afficher pour le moment.',
noneChosen: 'Aucun',
- answeredInChat: 'Répondu dans le chat',
noAnswer: 'Pas de réponse',
skippedAll: 'Configuration ignorée',
skip: 'Ignorer la configuration',
diff --git a/apps/desktop/src/i18n/ja_first_run.ts b/apps/desktop/src/i18n/ja_first_run.ts
index 8d6d25646ec..6833218ef19 100644
--- a/apps/desktop/src/i18n/ja_first_run.ts
+++ b/apps/desktop/src/i18n/ja_first_run.ts
@@ -17,7 +17,6 @@ export const jaFirstRun: FirstRunCopy = {
loading: '読み込み中…',
noPlugins: '現在表示できるプラグインはありません。',
noneChosen: 'なし',
- answeredInChat: 'チャットで回答済み',
noAnswer: '回答なし',
skippedAll: 'セットアップをスキップしました',
skip: 'セットアップをスキップ',
diff --git a/apps/desktop/src/i18n/ru_first_run.ts b/apps/desktop/src/i18n/ru_first_run.ts
index 8bc19f373fc..ec4fe565fe3 100644
--- a/apps/desktop/src/i18n/ru_first_run.ts
+++ b/apps/desktop/src/i18n/ru_first_run.ts
@@ -17,7 +17,6 @@ export const ruFirstRun: FirstRunCopy = {
loading: 'Загрузка…',
noPlugins: 'Сейчас нет плагинов для показа.',
noneChosen: 'Нет',
- answeredInChat: 'Ответ дан в чате',
noAnswer: 'Нет ответа',
skippedAll: 'Настройка пропущена',
skip: 'Пропустить настройку',
diff --git a/apps/desktop/src/i18n/types_first_run.ts b/apps/desktop/src/i18n/types_first_run.ts
index fc7ed4187ea..b61d23d0b69 100644
--- a/apps/desktop/src/i18n/types_first_run.ts
+++ b/apps/desktop/src/i18n/types_first_run.ts
@@ -20,7 +20,6 @@ export interface FirstRunCopy {
noPlugins: string
/** A receipt for a card that settled with nothing chosen (no apps connected, no plugin installed). */
noneChosen: string
- answeredInChat: string
noAnswer: string
skippedAll: string
skip: string
diff --git a/apps/desktop/src/i18n/zh-hant_first_run.ts b/apps/desktop/src/i18n/zh-hant_first_run.ts
index b32296743b6..ce786902036 100644
--- a/apps/desktop/src/i18n/zh-hant_first_run.ts
+++ b/apps/desktop/src/i18n/zh-hant_first_run.ts
@@ -17,7 +17,6 @@ export const zhHantFirstRun: FirstRunCopy = {
loading: '正在載入…',
noPlugins: '目前沒有可顯示的外掛。',
noneChosen: '無',
- answeredInChat: '已在對話中回答',
noAnswer: '未回答',
skippedAll: '已略過設定',
skip: '略過設定',
diff --git a/apps/desktop/src/i18n/zh_first_run.ts b/apps/desktop/src/i18n/zh_first_run.ts
index 11e788f2277..c9b9da9599d 100644
--- a/apps/desktop/src/i18n/zh_first_run.ts
+++ b/apps/desktop/src/i18n/zh_first_run.ts
@@ -17,7 +17,6 @@ export const zhFirstRun: FirstRunCopy = {
loading: '正在加载…',
noPlugins: '暂时没有可显示的插件。',
noneChosen: '无',
- answeredInChat: '已在对话中回答',
noAnswer: '未回答',
skippedAll: '已跳过设置',
skip: '跳过设置',
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index 16d9d076d18..1417c268468 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -1521,7 +1521,6 @@
"fileMenu.revealUnavailable",
"findInPage.next",
"findInPage.previous",
- "firstRun.answeredInChat",
"firstRun.beats.build",
"firstRun.beats.connectors",
"firstRun.beats.layout",