Skip to content

The agent that grows with you

fix(desktop): setup card receipts use the card's own labels, and no card row draws blank

alt-glitch103eadb3d4fa
diff --git a/apps/desktop/src/components/assistant-ui/setup-beat/beat-cards.tsx b/apps/desktop/src/components/assistant-ui/setup-beat/beat-cards.tsx
index 57ce153651a..986841ac19f 100644
--- a/apps/desktop/src/components/assistant-ui/setup-beat/beat-cards.tsx
+++ b/apps/desktop/src/components/assistant-ui/setup-beat/beat-cards.tsx
@@ -40,7 +40,6 @@ export function NameCard({ onName, suggested }: { onName: (name: string) => void
>
<Input
aria-label={t.firstRun.namePlaceholder}
- autoFocus
className={cn('flex-1', CARD_INPUT_CLASS)}
onChange={event => setName(event.target.value)}
placeholder={t.firstRun.namePlaceholder}
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 b7ce966a548..b376329f937 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 { FIRST_RUN_LAYOUTS } from '@/components/assistant-ui/theme-picker/layout-picker-card'
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'
@@ -21,10 +22,11 @@ export const SETUP_BEAT_SHELL_CLASS = cn(
export type SetupBeatOutcome =
| { answer: SetupBeatAnswer; beat: SetupBeat; kind: 'answer' }
| { beat: SetupBeat; kind: 'said'; said: string }
- | { beat: SetupBeat | null; kind: 'skipped_all' | 'timed_out' }
+ | { beat: SetupBeat | null; kind: 'refused' | '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. */
+ * words, a skip, `done`, a refused call), which draws nothing. An error naming the beat is a card
+ * answer the backend refused. */
export function setupBeatOutcome(result: SetupBeatToolResult): null | SetupBeatOutcome {
const beat = result.beat ?? null
@@ -36,6 +38,10 @@ export function setupBeatOutcome(result: SetupBeatToolResult): null | SetupBeatO
return null
}
+ if (result.error !== undefined) {
+ return { beat, kind: 'refused' }
+ }
+
if (result.answer) {
return { answer: result.answer, beat, kind: 'answer' }
}
@@ -51,6 +57,14 @@ interface AnswerNames {
layout: (id: string) => string
none: string
themeAccent: string
+ tour: (answer: SetupBeatAnswer) => string
+}
+
+/** The tour card's label for an option id, in the app's language. */
+export function useTourLabel(): (id: string) => string | undefined {
+ const { t } = useI18n()
+
+ return id => Object.entries(t.firstRun.tours).find(([key]) => key === id)?.[1]
}
function answerText(beat: SetupBeat, answer: SetupBeatAnswer, names: AnswerNames): string {
@@ -73,7 +87,7 @@ function answerText(beat: SetupBeat, answer: SetupBeatAnswer, names: AnswerNames
return answer.name ?? ''
case 'tour':
- return answer.label ?? answer.tour ?? ''
+ return names.tour(answer)
case 'build':
return answer.label ?? answer.build ?? ''
@@ -90,15 +104,25 @@ function ReceiptLine({ outcome }: { outcome: Exclude<SetupBeatOutcome, { kind: '
const { t } = useI18n()
const copy = t.firstRun
const presets = useContributions(LAYOUTS_AREA)
+ const tour = useTourLabel()
+ const themeCopy = t.assistant.themePicker
+
+ const closed = { refused: copy.answerRefused, skipped_all: copy.skippedAll, timed_out: copy.noAnswer }
- const closed = { skipped_all: copy.skippedAll, timed_out: copy.noAnswer }
+ // The first-run layouts read as the card named them (Basic, Elite), not by their preset titles.
+ const layout = (id: string) => {
+ const choice = FIRST_RUN_LAYOUTS.find(row => row.id === id)
+
+ return choice ? themeCopy[choice.name] : (presets.find(preset => preset.id === id)?.title ?? id)
+ }
const text =
outcome.kind === 'answer'
? answerText(outcome.beat, outcome.answer, {
- layout: id => presets.find(preset => preset.id === id)?.title ?? id,
+ layout,
none: copy.noneChosen,
- themeAccent: t.assistant.themePicker.themeAccent
+ themeAccent: themeCopy.themeAccent,
+ tour: answer => tour(answer.tour ?? '') ?? answer.label ?? ''
})
: closed[outcome.kind]
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 8c9f7e57c64..0eeacc53d3c 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
@@ -11,7 +11,7 @@ import { SetupBeatTool } from './setup-beat-tool'
const view: SessionView = { ...PRIMARY_SESSION_VIEW, $runtimeId: atom('beat-session'), $storedId: atom('stored-beat') }
-function renderRow(result: SetupBeatToolResult) {
+function renderRow(result: SetupBeatToolResult | undefined) {
// SAFETY: SetupBeatTool reads only result (and the session's requests when result is absent).
const row = { args: {}, result, toolCallId: 'call-1', toolName: 'setup_beat' } as ToolCallMessagePartProps
@@ -40,4 +40,13 @@ describe('SetupBeatTool', () => {
expect(container.innerHTML).toBe('')
})
+
+ it('says a card answer was not accepted, and a row left without a card once the turn ended was not answered', () => {
+ renderRow({ beat: 'layout', error: 'The card sent an answer this beat does not accept.' })
+ expect(screen.getByText('Answer not accepted')).not.toBeNull()
+ cleanup()
+
+ renderRow(undefined)
+ expect(screen.getByText('No answer')).not.toBeNull()
+ })
})
diff --git a/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.tsx b/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.tsx
index 0eba297a441..5a029f11e20 100644
--- a/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/setup-beat/setup-beat-tool.tsx
@@ -25,11 +25,18 @@ import {
import { NameCard, OptionsCard } from './beat-cards'
import { CARD_LABEL_CLASS } from './card-type'
import { PluginsCard } from './plugins-card'
-import { SETUP_BEAT_SHELL_CLASS, type SetupBeatOutcome, setupBeatOutcome, SetupBeatReceipt } from './receipt'
+import {
+ SETUP_BEAT_SHELL_CLASS,
+ type SetupBeatOutcome,
+ setupBeatOutcome,
+ SetupBeatReceipt,
+ useTourLabel
+} from './receipt'
/** The card body for one beat; `answer` sends the beat's picks and settles the card. */
function BeatBody({ answer, request }: { answer: (picks: SetupBeatAnswer) => boolean; request: SetupBeatRequest }) {
const { card } = request
+ const tourLabel = useTourLabel()
const commit = (applied: boolean, picks: SetupBeatAnswer): boolean => applied && answer(picks)
@@ -62,7 +69,10 @@ function BeatBody({ answer, request }: { answer: (picks: SetupBeatAnswer) => boo
case 'tour':
return (
- <OptionsCard onPick={option => answer({ label: option.label, tour: option.id })} options={card.options ?? []} />
+ <OptionsCard
+ onPick={option => answer({ label: option.label, tour: option.id })}
+ options={(card.options ?? []).map(option => ({ ...option, label: tourLabel(option.id) ?? option.label }))}
+ />
)
case 'build':
@@ -106,19 +116,14 @@ function BeatShell({ beat, children, question }: { beat: SetupBeat; children: Re
/** The setup_beat tool row: the beat's card while its request waits, then a one-line receipt where the
* choice happened. A card closed by words in the composer or by the deadline collapses the same way. */
export function SetupBeatTool(props: ToolCallMessagePartProps) {
- const sessionId = useStore(useSessionView().$runtimeId)
+ const view = useSessionView()
+ const sessionId = useStore(view.$runtimeId)
+ const busy = useStore(view.$busy)
const requests = useStore($setupBeatRequests)
const [settled, setSettled] = useState<null | SetupBeatOutcome>(null)
if (props.result !== undefined) {
- const result = setupBeatResult(props.result)
-
- // A refusal is addressed to the model (e.g. a beat set_theme already settled); the user has nothing to act on.
- if (result.error !== undefined) {
- return null
- }
-
- const outcome = setupBeatOutcome(result)
+ const outcome = setupBeatOutcome(setupBeatResult(props.result))
return outcome ? <SetupBeatReceipt outcome={outcome} /> : null
}
@@ -128,10 +133,12 @@ export function SetupBeatTool(props: ToolCallMessagePartProps) {
return <SetupBeatReceipt outcome={settled} />
}
- const request = sessionId ? requests[sessionId] : undefined
+ const pending = sessionId ? requests[sessionId] : undefined
+ const request = pending && (pending.toolCallId ?? props.toolCallId) === props.toolCallId ? pending : undefined
if (!sessionId || !request) {
- return null
+ // A row left without a result and no card for it once the turn is over (a crash, a restart).
+ return busy ? null : <SetupBeatReceipt outcome={{ beat: null, kind: 'timed_out' }} />
}
const answer = (picks: SetupBeatAnswer): boolean => {
diff --git a/apps/desktop/src/components/assistant-ui/theme-picker/layout-picker-card.tsx b/apps/desktop/src/components/assistant-ui/theme-picker/layout-picker-card.tsx
index 8ecc540d83e..983f8347b05 100644
--- a/apps/desktop/src/components/assistant-ui/theme-picker/layout-picker-card.tsx
+++ b/apps/desktop/src/components/assistant-ui/theme-picker/layout-picker-card.tsx
@@ -22,7 +22,7 @@ export interface LayoutPickerCardProps {
}
/** Basic is the Simple shell's sidebar-left; Elite is the Advanced terminal deck. */
-const CHOICES = [
+export const FIRST_RUN_LAYOUTS = [
{ id: 'sidebar-left', name: 'basic', detail: 'basicDetail' },
{ id: 'terminal-deck', name: 'elite', detail: 'eliteDetail' }
] as const
@@ -39,7 +39,7 @@ export function LayoutPickerCard({ onContinue }: LayoutPickerCardProps) {
return (
<div className="grid gap-3">
<div className="grid grid-cols-2 gap-3 p-1" role="group">
- {CHOICES.map(choice => {
+ {FIRST_RUN_LAYOUTS.map(choice => {
const tree = presets.find(preset => preset.id === choice.id)?.data
const active = choice.id === (staged ?? activeId)
diff --git a/apps/desktop/src/i18n/ar_first_run.ts b/apps/desktop/src/i18n/ar_first_run.ts
index 2176b67e555..c10deace3ef 100644
--- a/apps/desktop/src/i18n/ar_first_run.ts
+++ b/apps/desktop/src/i18n/ar_first_run.ts
@@ -18,6 +18,12 @@ export const arFirstRun: FirstRunCopy = {
noPlugins: 'لا توجد إضافات لعرضها الآن.',
noneChosen: 'لا شيء',
noAnswer: 'لا توجد إجابة',
+ answerRefused: 'لم تُقبل الإجابة',
+ tours: {
+ quick: 'جولة سريعة',
+ full: 'أرني كل شيء',
+ skip: 'تخطَّ، لنصنع شيئًا'
+ },
skippedAll: 'تم تخطي الإعداد',
skip: 'تخطي الإعداد',
skipTip: 'إنهاء الإعداد الموجَّه وفتح محادثة جديدة.',
diff --git a/apps/desktop/src/i18n/de_first_run.ts b/apps/desktop/src/i18n/de_first_run.ts
index d6fb6520e06..d190ad7cf42 100644
--- a/apps/desktop/src/i18n/de_first_run.ts
+++ b/apps/desktop/src/i18n/de_first_run.ts
@@ -18,6 +18,12 @@ export const deFirstRun: FirstRunCopy = {
noPlugins: 'Gerade keine Plugins verfügbar.',
noneChosen: 'Keine',
noAnswer: 'Keine Antwort',
+ answerRefused: 'Antwort nicht angenommen',
+ tours: {
+ quick: 'Kurze Tour',
+ full: 'Zeig mir alles',
+ skip: 'Überspringen, lass uns etwas bauen'
+ },
skippedAll: 'Einrichtung übersprungen',
skip: 'Einrichtung überspringen',
skipTip: 'Beendet die geführte Einrichtung und öffnet einen neuen Chat.',
diff --git a/apps/desktop/src/i18n/en_first_run.ts b/apps/desktop/src/i18n/en_first_run.ts
index 8712e358eb2..cf7384b3d97 100644
--- a/apps/desktop/src/i18n/en_first_run.ts
+++ b/apps/desktop/src/i18n/en_first_run.ts
@@ -18,6 +18,12 @@ export const enFirstRun: FirstRunCopy = {
noPlugins: 'No plugins to show right now.',
noneChosen: 'None',
noAnswer: 'No answer',
+ answerRefused: 'Answer not accepted',
+ tours: {
+ quick: 'Quick tour',
+ full: 'Show me everything',
+ skip: 'Skip, let\'s build something'
+ },
skippedAll: 'Setup skipped',
skip: 'Skip setup',
skipTip: 'End the guided setup and open a new chat.',
diff --git a/apps/desktop/src/i18n/es_first_run.ts b/apps/desktop/src/i18n/es_first_run.ts
index bb7c50a3e77..b4dbcd6699c 100644
--- a/apps/desktop/src/i18n/es_first_run.ts
+++ b/apps/desktop/src/i18n/es_first_run.ts
@@ -18,6 +18,12 @@ export const esFirstRun: FirstRunCopy = {
noPlugins: 'No hay plugins para mostrar ahora mismo.',
noneChosen: 'Ninguno',
noAnswer: 'Sin respuesta',
+ answerRefused: 'Respuesta no aceptada',
+ tours: {
+ quick: 'Recorrido rápido',
+ full: 'Muéstramelo todo',
+ skip: 'Omitir, construyamos algo'
+ },
skippedAll: 'Configuración omitida',
skip: 'Omitir configuración',
skipTip: 'Termina la configuración guiada y abre un chat nuevo.',
diff --git a/apps/desktop/src/i18n/fr_first_run.ts b/apps/desktop/src/i18n/fr_first_run.ts
index fd11bacb432..fce7bd4afe1 100644
--- a/apps/desktop/src/i18n/fr_first_run.ts
+++ b/apps/desktop/src/i18n/fr_first_run.ts
@@ -18,6 +18,12 @@ export const frFirstRun: FirstRunCopy = {
noPlugins: 'Aucun plugin à afficher pour le moment.',
noneChosen: 'Aucun',
noAnswer: 'Pas de réponse',
+ answerRefused: 'Réponse non acceptée',
+ tours: {
+ quick: 'Visite rapide',
+ full: 'Montre-moi tout',
+ skip: 'Passer, construisons quelque chose'
+ },
skippedAll: 'Configuration ignorée',
skip: 'Ignorer la configuration',
skipTip: 'Termine la configuration guidée et ouvre une nouvelle discussion.',
diff --git a/apps/desktop/src/i18n/ja_first_run.ts b/apps/desktop/src/i18n/ja_first_run.ts
index 1dd693e118f..f151a2c8d3e 100644
--- a/apps/desktop/src/i18n/ja_first_run.ts
+++ b/apps/desktop/src/i18n/ja_first_run.ts
@@ -18,6 +18,12 @@ export const jaFirstRun: FirstRunCopy = {
noPlugins: '現在表示できるプラグインはありません。',
noneChosen: 'なし',
noAnswer: '回答なし',
+ answerRefused: '回答は受け付けられませんでした',
+ tours: {
+ quick: 'クイックツアー',
+ full: 'すべて見せて',
+ skip: 'スキップして何か作ろう'
+ },
skippedAll: 'セットアップをスキップしました',
skip: 'セットアップをスキップ',
skipTip: 'ガイド付きセットアップを終了し、新しいチャットを開きます。',
diff --git a/apps/desktop/src/i18n/ru_first_run.ts b/apps/desktop/src/i18n/ru_first_run.ts
index 986b8f5b3b2..2440d3e6a0a 100644
--- a/apps/desktop/src/i18n/ru_first_run.ts
+++ b/apps/desktop/src/i18n/ru_first_run.ts
@@ -18,6 +18,12 @@ export const ruFirstRun: FirstRunCopy = {
noPlugins: 'Сейчас нет плагинов для показа.',
noneChosen: 'Нет',
noAnswer: 'Нет ответа',
+ answerRefused: 'Ответ не принят',
+ tours: {
+ quick: 'Быстрый тур',
+ full: 'Покажи всё',
+ skip: 'Пропустить, давай что-нибудь сделаем'
+ },
skippedAll: 'Настройка пропущена',
skip: 'Пропустить настройку',
skipTip: 'Завершить пошаговую настройку и открыть новый чат.',
diff --git a/apps/desktop/src/i18n/types_first_run.ts b/apps/desktop/src/i18n/types_first_run.ts
index 36b8211b377..abb7d1f06a1 100644
--- a/apps/desktop/src/i18n/types_first_run.ts
+++ b/apps/desktop/src/i18n/types_first_run.ts
@@ -21,6 +21,14 @@ export interface FirstRunCopy {
/** A receipt for a card that settled with nothing chosen (no apps connected, no plugin installed). */
noneChosen: string
noAnswer: string
+ /** A card answer the backend refused; the model brings the card back. */
+ answerRefused: string
+ /** The tour card's options by id; the backend's labels are English. */
+ tours: {
+ quick: string
+ full: string
+ skip: string
+ }
skippedAll: string
skip: string
skipTip: string
diff --git a/apps/desktop/src/i18n/zh-hant_first_run.ts b/apps/desktop/src/i18n/zh-hant_first_run.ts
index 5719c2031ac..b855eab0205 100644
--- a/apps/desktop/src/i18n/zh-hant_first_run.ts
+++ b/apps/desktop/src/i18n/zh-hant_first_run.ts
@@ -18,6 +18,12 @@ export const zhHantFirstRun: FirstRunCopy = {
noPlugins: '目前沒有可顯示的外掛。',
noneChosen: '無',
noAnswer: '未回答',
+ answerRefused: '未接受該回答',
+ tours: {
+ quick: '快速導覽',
+ full: '全部展示給我',
+ skip: '略過,來做點東西'
+ },
skippedAll: '已略過設定',
skip: '略過設定',
skipTip: '結束引導設定並開啟新對話。',
diff --git a/apps/desktop/src/i18n/zh_first_run.ts b/apps/desktop/src/i18n/zh_first_run.ts
index 1da0fab8f8c..75d13b3019a 100644
--- a/apps/desktop/src/i18n/zh_first_run.ts
+++ b/apps/desktop/src/i18n/zh_first_run.ts
@@ -18,6 +18,12 @@ export const zhFirstRun: FirstRunCopy = {
noPlugins: '暂时没有可显示的插件。',
noneChosen: '无',
noAnswer: '未回答',
+ answerRefused: '未接受该回答',
+ tours: {
+ quick: '快速导览',
+ full: '全部展示给我',
+ skip: '跳过,来做点东西'
+ },
skippedAll: '已跳过设置',
skip: '跳过设置',
skipTip: '结束引导设置并打开新对话。',
diff --git a/apps/desktop/src/store/setup-beat.test.ts b/apps/desktop/src/store/setup-beat.test.ts
index 5f92a8ba0b6..90a35ce855d 100644
--- a/apps/desktop/src/store/setup-beat.test.ts
+++ b/apps/desktop/src/store/setup-beat.test.ts
@@ -6,15 +6,25 @@ import { setupBeatOutcome } from '@/components/assistant-ui/setup-beat/receipt'
import { $onboardingSession } from './onboarding-session'
import { answerParkedCard, parkedCardWaiting, sessionOnboardingCardWaiting } from './parked-card-answers'
import { rememberServerRequest, resetServerRequestsForTests } from './server-requests'
-import { $setupBeatRequests, clearSetupBeat, parkSetupBeat } from './setup-beat'
+import { $setupBeatRequests, answerSetupBeat, clearSetupBeat, dropSetupBeatForCall, parkSetupBeat } from './setup-beat'
-function parkNameCard(requestId: string) {
+function parkNameCard(requestId: string, open = true) {
const respond = vi.fn()
const request: ServerRequest = { fail: vi.fn(), id: requestId, method: 'setup_beat', params: { session_id: 'rt-1' }, respond }
- rememberServerRequest(request)
- parkSetupBeat({ beat: 'name', card: {}, question: 'What should I call you?', requestId, sessionId: 'rt-1' })
+ if (open) {
+ rememberServerRequest(request)
+ }
+
+ parkSetupBeat({
+ beat: 'name',
+ card: {},
+ question: 'What should I call you?',
+ requestId,
+ sessionId: 'rt-1',
+ toolCallId: `call-${requestId}`
+ })
return respond
}
@@ -58,11 +68,24 @@ describe('setup_beat card', () => {
off()
})
+ it('keeps a card whose answer could not be sent, and drops it once its call finishes elsewhere', () => {
+ parkNameCard('srq-4', false)
+
+ expect(answerSetupBeat('rt-1', { name: 'Sid' })).toBe(false)
+ expect($setupBeatRequests.get()['rt-1']?.requestId).toBe('srq-4')
+
+ dropSetupBeatForCall('rt-1', 'call-other')
+ expect($setupBeatRequests.get()['rt-1']).toBeDefined()
+ dropSetupBeatForCall('rt-1', 'call-srq-4')
+ expect($setupBeatRequests.get()['rt-1']).toBeUndefined()
+ })
+
it('collapses every way a card can close to a receipt, and draws nothing for a card-less call', () => {
expect(setupBeatOutcome({ answer: { name: 'Sid' }, beat: 'name' })).toMatchObject({ kind: 'answer' })
expect(setupBeatOutcome({ beat: 'theme', said: 'make it violet' })).toMatchObject({ kind: 'said' })
expect(setupBeatOutcome({ beat: 'layout', timed_out: true })).toMatchObject({ kind: 'timed_out' })
expect(setupBeatOutcome({ skipped_all: true })).toMatchObject({ kind: 'skipped_all' })
+ expect(setupBeatOutcome({ beat: 'build', error: 'not accepted' })).toMatchObject({ kind: 'refused' })
expect(setupBeatOutcome({ completed: true })).toBeNull()
})
})
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index 2dbbba4e5ea..9ceeec1747a 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -1521,6 +1521,7 @@
"fileMenu.revealUnavailable",
"findInPage.next",
"findInPage.previous",
+ "firstRun.answerRefused",
"firstRun.beats.build",
"firstRun.beats.connectors",
"firstRun.beats.layout",
@@ -1547,6 +1548,9 @@
"firstRun.skipFailed",
"firstRun.skipTip",
"firstRun.skippedAll",
+ "firstRun.tours.full",
+ "firstRun.tours.quick",
+ "firstRun.tours.skip",
"firstRun.useName",
"freeTier.alreadySignedInBody",
"freeTier.alreadySignedInHeading",