The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): onboarding boots into the setup chat and the setup cards keep their picks
alt-glitch5f461df6055a
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff.ts b/apps/desktop/src/app/contrib/onboarding-kickoff.tsindex 2c665c5de1c..740c4769ebc 100644--- a/apps/desktop/src/app/contrib/onboarding-kickoff.ts+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.ts@@ -155,7 +155,7 @@ export function useOnboardingKickoff({ requestGateway, resumeSession }: Onboardicapabilities)- const setupChat = await guideRequest<OnboardingEnsureSetupSessionResult>('onboarding.ensure_setup_session', {+ const setupChat = await requestGateway<OnboardingEnsureSetupSessionResult>('onboarding.ensure_setup_session', {messages: seedMessages})diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 26743e0440e..fda72e44bf8 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -688,7 +688,29 @@ export function ContribWiring({ children }: { children: ReactNode }) {}}, [])- const kickoffFirstChat = useOnboardingKickoff({ requestGateway, resumeSession })+ const adoptSessionRoute = useCallback(+ async (storedSessionId: string) => {+ creatingSessionRef.current = true++ try {+ await resumeSession(storedSessionId, true)++ if ($selectedStoredSessionId.get() === storedSessionId) {+ navigate(sessionRoute(storedSessionId), { replace: true })+ }+ } finally {+ window.setTimeout(() => {+ creatingSessionRef.current = false+ }, 0)+ }+ },+ [navigate, resumeSession]+ )++ const kickoffFirstChat = useOnboardingKickoff({+ requestGateway: ambientRequestGateway,+ resumeSession: adoptSessionRoute+ })useOnboardingHandoff({activeSessionIdRef,diff --git a/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts b/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.tsindex def633a46dd..a17017d5e8a 100644--- a/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts+++ b/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts@@ -4,10 +4,12 @@ import { visibleClarifyCard } from '@/lib/keybinds/composer-focus-keys'import type { ClarifyQuestion } from '@/store/clarify'interface ClarifyKeysOptions {+ columns?: numberenabled: booleanformRef: RefObject<HTMLFormElement | null>- isStaged: (question: ClarifyQuestion) => boolean- onClear: (question: ClarifyQuestion) => void+ initialRow?: number+ isStaged: (question: ClarifyQuestion, row?: number) => boolean+ onClear?: (question: ClarifyQuestion) => voidonConfirm: () => voidonToggle: (question: ClarifyQuestion, choice: string) => voidother?: boolean@@ -16,8 +18,10 @@ interface ClarifyKeysOptions {}export function useClarifyKeys({+ columns,enabled,formRef,+ initialRow = 0,isStaged,onClear,onConfirm,@@ -26,7 +30,7 @@ export function useClarifyKeys({questions,shortcuts}: ClarifyKeysOptions) {- const [cursor, setCursor] = useState({ question: 0, row: 0 })+ const [cursor, setCursor] = useState({ question: 0, row: initialRow })const questionIndex = Math.min(cursor.question, Math.max(questions.length - 1, 0))const active = questions[questionIndex]const choices = active?.choices ?? []@@ -95,17 +99,17 @@ export function useClarifyKeys({)const move = useCallback(- (delta: number) => {- if (!active) {+ (delta: number, wrap = true) => {+ const itemCount = choices.length + otherRows++ if (!active || (!wrap && (row + delta < 0 || row + delta >= itemCount))) {return}if (!active.multiSelect) {- onClear(active)+ onClear?.(active)}- const itemCount = choices.length + otherRows-setCursor({ question: questionIndex, row: (row + delta + itemCount) % itemCount })},[active, choices.length, onClear, otherRows, questionIndex, row]@@ -124,7 +128,7 @@ export function useClarifyKeys({return}- if (isStaged(active)) {+ if (isStaged(active, row)) {onConfirm()return@@ -184,7 +188,16 @@ export function useClarifyKeys({if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {if (choices.length > 0) {event.preventDefault()- move(event.key === 'ArrowDown' ? 1 : -1)+ move((event.key === 'ArrowDown' ? 1 : -1) * (columns ?? 1), columns === undefined)+ }++ return+ }++ if ((event.key === 'ArrowRight' || event.key === 'ArrowLeft') && columns !== undefined) {+ if (choices.length > 0) {+ event.preventDefault()+ move(event.key === 'ArrowRight' ? 1 : -1)}return@@ -217,7 +230,20 @@ export function useClarifyKeys({window.addEventListener('keydown', onKeyDown)return () => window.removeEventListener('keydown', onKeyDown)- }, [activate, active, choices.length, enabled, focusOther, formRef, move, other, pick, questionIndex, shortcutRows])+ }, [+ activate,+ active,+ choices.length,+ columns,+ enabled,+ focusOther,+ formRef,+ move,+ other,+ pick,+ questionIndex,+ shortcutRows+ ])return { activeQuestion: questionIndex, cursorRow: row, focusQuestion, onOtherFocus, pick }}diff --git a/apps/desktop/src/components/assistant-ui/clarify/pending.tsx b/apps/desktop/src/components/assistant-ui/clarify/pending.tsxindex 50867e7ba45..1985f31b66f 100644--- a/apps/desktop/src/components/assistant-ui/clarify/pending.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/pending.tsx@@ -285,7 +285,7 @@ export function ClarifyToolPending({<ClarifyShell className="grid gap-3"><div className="flex items-start gap-2"><span className="flex-1 text-[0.6875rem] leading-4 text-(--ui-text-tertiary)">- {copy.questionProgress(answeredCount, questions.length)}+ {questions.length === 1 ? copy.oneQuestion : copy.questionProgress(answeredCount, questions.length)}</span><MessageQuestion aria-hidden className={CLARIFY_ICON_CLASS} /></div>diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx b/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsxindex 39046b865d0..a504a477859 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx@@ -1,15 +1,25 @@'use client'-import type { SetupChooseIntent, SetupChooseKind } from '@hermes/shared'+import type { SetupChooseKind } from '@hermes/shared'import { useStore } from '@nanostores/react'import { Puzzle } from 'lucide-react'-import { type ComponentType, type FormEvent, useCallback, useMemo, useRef, useState } from 'react'+import { type ComponentType, type FormEvent, useCallback, useMemo, useRef } from 'react'import { useSessionView } from '@/app/chat/session-view'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'import { LayoutDashboard, MessageQuestion, Moon, Palette, Plug } from '@/lib/icons'-import { type ClarifyQuestion, type ClarifyRequest, clearClarifyRequest, SETUP_CHOOSE_QID } from '@/store/clarify'+import {+ $setupChooseStages,+ type ClarifyQuestion,+ type ClarifyRequest,+ clearClarifyRequest,+ commitSetupChoose,+ EMPTY_SETUP_STAGE,+ SETUP_CHOOSE_QID,+ setupChooseStage,+ stageSetupChoose+} from '@/store/clarify'import { notifyError } from '@/store/notifications'import { respondToServerRequest } from '@/store/server-requests'import { useTheme } from '@/themes'@@ -18,8 +28,15 @@ import { ClarifyConfirmBar } from './core/confirm-bar'import { QuestionBlock } from './core/question-block'import { CLARIFY_ICON_CLASS, ClarifyShell } from './core/shell'import { useClarifyKeys } from './core/use-clarify-keys'-import { pickerShortcutCount, SETUP_PICKERS, SetupIntentRows } from './setup-pickers'-import { LIVE_APPLY, useSetupRows } from './setup-rows'+import {+ PICKER_COLUMNS,+ pickerShortcutCount,+ pillQuestion,+ QuestionPills,+ SETUP_PICKERS,+ SetupIntentRows+} from './setup-pickers'+import { LIVE_LOOK, useSetupRows } from './setup-rows'import { handleClarifySubmitShortcut } from './submit-shortcut'import { UndeliveredNotice } from './undelivered-notice'@@ -49,7 +66,7 @@ export function SetupChoosePending({const copy = t.assistant.clarifyconst setupCopy = t.assistant.setupChooseconst storedId = useStore(useSessionView().$storedId)- const { setMode } = useTheme()+ const { mode, setMode } = useTheme()const ready = Boolean(request?.requestId && request.setup)const source = request ?? fromArgs@@ -59,9 +76,9 @@ export function SetupChoosePending({const freeText = pickerKind === nullconst rows = useSetupRows(setup, storedId)- const [picked, setPicked] = useState<string[]>([])- const [draft, setDraft] = useState('')- const [intents, setIntents] = useState<Record<string, SetupChooseIntent>>({})+ const requestId = ready ? (request?.requestId ?? null) : null+ const stages = useStore($setupChooseStages)+ const { draft, intents, picked } = (requestId && stages[requestId]) || EMPTY_SETUP_STAGEconst question: ClarifyQuestion = useMemo(() => ({@@ -87,21 +104,26 @@ export function SetupChoosePending({const stage = useCallback((id: string) => {- const removing = question.multiSelect && picked.includes(id)-- setPicked(current =>- question.multiSelect ? (removing ? current.filter(value => value !== id) : [...current, id]) : [id]- )-- if (!question.multiSelect) {- setDraft('')+ if (!requestId) {+ return}- if (!removing) {- LIVE_APPLY[kind]?.(id, setMode)- }+ const current = setupChooseStage(requestId)+ const removing = question.multiSelect && current.picked.includes(id)+ const live = removing ? undefined : LIVE_LOOK[kind]++ stageSetupChoose(requestId, {+ picked: question.multiSelect+ ? removing+ ? current.picked.filter(value => value !== id)+ : [...current.picked, id]+ : [id],+ revert: current.revert ?? live?.snapshot(mode, setMode) ?? null,+ ...(question.multiSelect ? {} : { draft: '' })+ })+ live?.apply(id, setMode)},- [kind, picked, question.multiSelect, setMode]+ [kind, mode, question.multiSelect, requestId, setMode])const toggle = useCallback(@@ -117,13 +139,11 @@ export function SetupChoosePending({const onDraft = useCallback((value: string) => {- setDraft(value)-- if (!question.multiSelect) {- setPicked([])+ if (requestId) {+ stageSetupChoose(requestId, { draft: value, ...(question.multiSelect ? {} : { picked: [] }) })}},- [question.multiSelect]+ [question.multiSelect, requestId])const confirm = useCallback(() => {@@ -142,6 +162,7 @@ export function SetupChoosePending({triggerHaptic('submit')onAnswered()+ commitSetupChoose(request.requestId)clearClarifyRequest(request.requestId, request.sessionId)}, [answer, copy, intents, onAnswered, picked, request, rows, setup?.intent])@@ -169,12 +190,17 @@ export function SetupChoosePending({const formRef = useRef<HTMLFormElement | null>(null)const questions = useMemo(() => [question], [question])const shortcuts = pickerKind === null ? (question.choices?.length ?? 0) : pickerShortcutCount(rows ?? [])+ const pills = pickerKind === null && pillQuestion(rows ?? [])const keys = useClarifyKeys({+ columns: pickerKind === null ? undefined : PICKER_COLUMNS[pickerKind](rows ?? []),enabled: ready,formRef,- isStaged: () => answer !== null,- onClear: () => setPicked([]),+ initialRow: Math.max(0, rows?.findIndex(row => row.id === picked[0]) ?? 0),+ isStaged: (_question, row) =>+ answer !== null &&+ (pickerKind === null || question.multiSelect || row === undefined || picked.includes(rows?.[row]?.id ?? '')),+ onClear: pickerKind === null && requestId ? () => stageSetupChoose(requestId, { picked: [] }) : undefined,onConfirm: confirm,onToggle: toggle,other: freeText,@@ -208,12 +234,26 @@ export function SetupChoosePending({<ClarifyShell className="grid gap-3"><div className="flex items-start gap-2"><span className="flex-1 text-[0.6875rem] leading-4 text-(--ui-text-tertiary)">- {pickerKind === null ? copy.questionProgress(answer === null ? 0 : 1, 1) : setupCopy.kinds[pickerKind]}+ {pickerKind === null ? copy.oneQuestion : setupCopy.kinds[pickerKind]}</span><Icon aria-hidden className={CLARIFY_ICON_CLASS} /></div>{undelivered ? <UndeliveredNotice /> : null}- {Picker === null ? (+ {Picker === null && pills ? (+ <QuestionPills+ cursor={cursor}+ disabled={!ready}+ onActivate={() => keys.focusQuestion(0)}+ onDraft={onDraft}+ onOtherFocus={() => keys.onOtherFocus(0)}+ onPick={index => keys.pick(0, index)}+ question={question}+ staged={{+ choices: (rows ?? []).filter(row => picked.includes(row.id)).map(row => row.label),+ draft+ }}+ />+ ) : Picker === null ? (<QuestionBlockcursor={cursor}disabled={!ready}@@ -256,7 +296,10 @@ export function SetupChoosePending({)}<SetupIntentRowsintents={intents}- onIntent={(id, intent) => setIntents(current => ({ ...current, [id]: intent }))}+ onIntent={(id, intent) =>+ requestId &&+ stageSetupChoose(requestId, { intents: { ...setupChooseStage(requestId).intents, [id]: intent } })+ }rows={intentRows}/></fieldset>diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsxindex 12548c9222d..7dc4715b1c1 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx@@ -1,19 +1,26 @@'use client'import type { SetupChooseIntent, SetupChooseKind } from '@hermes/shared'+import { useStore } from '@nanostores/react'import { Puzzle } from 'lucide-react'-import { type FC, type ReactNode, useState } from 'react'+import { type CSSProperties, type FC, type ReactNode, useState } from 'react'+import { useSessionView } from '@/app/chat/session-view'import { Chip } from '@/components/onboarding-chat/chip'import { AccentSwatch, LayoutPreviewCard, LAYOUTS, NOUS_ACCENT } from '@/components/onboarding-chat/options'import { ConnectorLogo } from '@/components/ui/connector-logo'+import { Kbd } from '@/components/ui/kbd'import { SearchField } from '@/components/ui/search-field'import { SegmentedControl } from '@/components/ui/segmented-control'import { useI18n } from '@/i18n'import { connectorIconUrl } from '@/lib/connector-tools'import { cn } from '@/lib/utils'+import type { ClarifyQuestion } from '@/store/clarify'+import { pluginNeedsApp, useOnboardingPluginList } from '@/store/onboarding-plugins'+import { useTheme } from '@/themes'+import { getBaseColors } from '@/themes/context'-import { ChoiceButton, letterFor } from './core/choice-row'+import { ChoiceLabel, letterFor } from './core/choice-row'import type { SetupRow } from './setup-rows'export interface SetupPickerProps {@@ -26,6 +33,23 @@ export interface SetupPickerProps {const SEARCH_THRESHOLD = 12+const PILL_MAX_OPTIONS = 6++const PILL_MAX_LABEL = 40++export const PICKER_COLUMNS: Record<Exclude<SetupChooseKind, 'question'>, (rows: SetupRow[]) => number> = {+ accent: rows => rows.length,+ connectors: () => 3,+ layout: () => 2,+ plugins: () => 3,+ theme: rows => rows.length+}++export const pillQuestion = (rows: SetupRow[]): boolean =>+ rows.length > 0 &&+ rows.length <= PILL_MAX_OPTIONS &&+ rows.every(row => !row.detail && row.label.length <= PILL_MAX_LABEL)+const INTENTS: readonly SetupChooseIntent[] = ['now', 'later', 'save']export function pickerShortcutCount(rows: SetupRow[]): number {@@ -46,7 +70,7 @@ function PickerItem({return (<divaria-keyshortcuts={index === null ? undefined : `${letterFor(index)} ${index + 1}`}- className={cn('min-w-0', active && 'ring-2 ring-primary/40', className)}+ className={cn('grid min-w-0', active && 'ring-2 ring-primary/40', className)}data-highlighted={active || undefined}onMouseDown={event => event.preventDefault()}>@@ -56,19 +80,46 @@ function PickerItem({}function ThemePicker({ cursor, onPick, picked, rows }: SetupPickerProps) {+ const { themeName } = useTheme()+ const light = getBaseColors(themeName, 'light')+ const dark = getBaseColors(themeName, 'dark')++ const palettes: Record<string, CSSProperties> = {+ dark: {+ background: dark.background,+ borderColor: dark.border,+ '--color-foreground': dark.foreground+ } as CSSProperties,+ light: {+ background: light.background,+ borderColor: light.border,+ '--color-foreground': light.foreground+ } as CSSProperties,+ system: {+ background: `linear-gradient(135deg, ${light.background} 50%, ${dark.background} 50%)`,+ borderColor: light.border,+ '--color-foreground': '#808080'+ } as CSSProperties+ }+return (- <div className="grid gap-px" role="group">- {rows.map((row, index) => (- <ChoiceButton- active={cursor === index}- char={letterFor(index)}- choice={row.label}- key={row.id}- keyShortcuts={`${letterFor(index)} ${index + 1}`}- onClick={() => onPick(index)}- selected={picked.includes(row.id)}- />- ))}+ <div className="grid grid-cols-3 gap-3 p-1" role="group">+ {rows.map((row, index) => {+ const active = picked.includes(row.id)+ const palette = palettes[row.id]++ return (+ <PickerItem active={cursor === index} className="rounded-[8px]" index={index} key={row.id}>+ <LayoutPreviewCard+ active={active}+ name={row.label}+ onSelect={() => onPick(index)}+ previewStyle={active && palette ? { ...palette, borderColor: undefined } : palette}+ tree={LAYOUTS[0].tree}+ />+ </PickerItem>+ )+ })}</div>)}@@ -115,12 +166,19 @@ function LayoutPicker({ cursor, onPick, picked, rows }: SetupPickerProps) {function ChipPicker({cursor,+ dim,+ footnote,icon,onPick,picked,rows,sub-}: SetupPickerProps & { icon: (row: SetupRow) => ReactNode; sub?: string }) {+}: SetupPickerProps & {+ dim?: (row: SetupRow) => boolean+ footnote?: ReactNode+ icon: (row: SetupRow) => ReactNode+ sub?: string+}) {const { t } = useI18n()const [query, setQuery] = useState('')const search = query.trim().toLowerCase()@@ -141,7 +199,7 @@ function ChipPicker({key={row.id}><Chip- className="w-full"+ className={cn('w-full', dim?.(row) && 'opacity-60')}icon={icon(row)}label={row.label}on={picked.includes(row.id)}@@ -152,6 +210,7 @@ function ChipPicker({))}</div>+ {footnote}</div>)}@@ -175,8 +234,24 @@ function ConnectorPicker(props: SetupPickerProps) {function PluginPicker(props: SetupPickerProps) {const { t } = useI18n()+ const copy = t.assistant.setupChoose+ const plugins = useOnboardingPluginList(useStore(useSessionView().$storedId))++ const needsApp = (row: SetupRow) => Boolean(plugins?.some(plugin => plugin.name === row.id && pluginNeedsApp(plugin)))- return <ChipPicker {...props} icon={pluginIcon} sub={t.assistant.setupChoose.plugin} />+ return (+ <ChipPicker+ {...props}+ dim={needsApp}+ footnote={+ <p className="text-xs text-muted-foreground">+ <strong className="font-medium text-foreground">{copy.nothingYet.lead}</strong> {copy.nothingYet.rest}+ </p>+ }+ icon={pluginIcon}+ sub={copy.plugin}+ />+ )}export const SETUP_PICKERS: Record<Exclude<SetupChooseKind, 'question'>, FC<SetupPickerProps>> = {@@ -218,3 +293,100 @@ export function SetupIntentRows({</div>)}++const PILL_CLASS =+ 'flex max-w-full shrink-0 items-center gap-1.5 rounded-full border py-1 pr-3 pl-1.5 text-left text-[12px] whitespace-normal wrap-anywhere transition-colors disabled:cursor-not-allowed disabled:opacity-50'++const PILL_CURSOR_CLASS = 'ring-2 ring-ring/60 ring-offset-2 ring-offset-(--dt-background)'++export function QuestionPills({+ cursor,+ disabled,+ onActivate,+ onDraft,+ onOtherFocus,+ onPick,+ question,+ staged+}: {+ cursor: null | number+ disabled: boolean+ onActivate: () => void+ onDraft: (value: string) => void+ onOtherFocus: () => void+ onPick: (index: number) => void+ question: ClarifyQuestion+ staged: { choices: string[]; draft: string }+}) {+ const { t } = useI18n()+ const choices = question.choices ?? []+ const otherActive = cursor === choices.length+ const drafted = Boolean(staged.draft.trim())++ return (+ <div+ className="grid gap-2"+ data-clarify-batch-question={question.qid}+ onFocus={onActivate}+ onPointerDown={onActivate}+ >+ <span className="whitespace-pre-wrap font-medium leading-(--conversation-line-height)">{question.question}</span>+ <div className="flex min-w-0 flex-wrap gap-2 p-1" role="group">+ {choices.map((choice, index) => {+ const selected = staged.choices.includes(choice)++ return (+ <button+ aria-current={cursor === index || undefined}+ aria-keyshortcuts={cursor === null ? undefined : `${letterFor(index)} ${index + 1}`}+ aria-pressed={selected}+ className={cn(+ PILL_CLASS,+ selected+ ? 'border-primary bg-primary text-primary-foreground'+ : 'border-border bg-card hover:border-primary/50 hover:bg-primary/10',+ cursor === index && PILL_CURSOR_CLASS+ )}+ data-choice+ data-highlighted={cursor === index || undefined}+ disabled={disabled}+ key={`${index}-${choice}`}+ onClick={() => onPick(index)}+ type="button"+ >+ <Kbd size="sm" variant={selected ? 'inverted' : 'default'}>+ {letterFor(index)}+ </Kbd>+ <span>+ <ChoiceLabel choice={choice} />+ </span>+ </button>+ )+ })}+ <label+ className={cn(+ PILL_CLASS,+ 'cursor-text',+ drafted ? 'border-primary bg-primary/10' : 'border-border bg-card',+ otherActive && PILL_CURSOR_CLASS,+ disabled && 'cursor-not-allowed opacity-50'+ )}+ data-highlighted={otherActive || undefined}+ >+ <Kbd size="sm">{letterFor(choices.length)}</Kbd>+ <textarea+ aria-current={otherActive || undefined}+ aria-keyshortcuts={cursor === null ? undefined : `${letterFor(choices.length)} ${choices.length + 1}`}+ className="field-sizing-content max-h-40 min-w-8 resize-none bg-transparent leading-5 outline-none placeholder:text-muted-foreground focus:min-w-48"+ disabled={disabled}+ onChange={event => onDraft(event.target.value)}+ onFocus={onOtherFocus}+ placeholder={t.assistant.clarify.other}+ rows={1}+ value={staged.draft}+ />+ </label>+ </div>+ </div>+ )+}diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-rows.ts b/apps/desktop/src/components/assistant-ui/clarify/setup-rows.tsindex 7910ad75ccd..999946057ba 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-rows.ts+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-rows.ts@@ -4,18 +4,19 @@ import { useQuery } from '@tanstack/react-query'import { listConnectors } from '@/app/capabilities/connectors/data/rpc'import { resolveSessionOwner } from '@/app/session/hooks/use-session-actions/utils'import { MODE_OPTIONS } from '@/app/settings/constants'-import { $chatLayoutPicked, assembleChatOnboarding } from '@/components/onboarding-chat/assembly'+import { $chatLayoutPicked, assembleChatOnboarding, snapshotChatLayout } from '@/components/onboarding-chat/assembly'import { accentsFor, LAYOUTS, NOUS_ACCENT, orderConnectorPicks } from '@/components/onboarding-chat/options'import type { LayoutNode } from '@/components/pane-shell/tree/model'import { registry } from '@/contrib/registry'import { useI18n } from '@/i18n'import { connectorTitle } from '@/lib/connector-tools'import type { SetupChooseSpec } from '@/store/clarify'+import { $onboardingAnswers, setOnboardingAnswers } from '@/store/onboarding-answers'import { type OnboardingPlugin, useOnboardingPluginList } from '@/store/onboarding-plugins'import { $activeGatewayProfile } from '@/store/profile'import { isSessionOwnerRoute } from '@/store/session-request-router'import { useTheme } from '@/themes'-import { setAccentOverride } from '@/themes/accent-override'+import { $accentOverride, setAccentOverride } from '@/themes/accent-override'import { normalizeHex } from '@/themes/color'import type { ThemeMode } from '@/themes/context'@@ -59,28 +60,53 @@ const APP_LABELS: Record<SetupChooseKind, (id: string, sources: Pick<RowSources,theme: (id, { t }) => modeLabel(id, t)}-export const LIVE_APPLY: Partial<Record<SetupChooseKind, (id: string, setMode: (mode: ThemeMode) => void) => void>> = {- accent: id => {- const hex = normalizeHex(id)+interface LiveLook {+ apply: (id: string, setMode: (mode: ThemeMode) => void) => void+ snapshot: (mode: ThemeMode, setMode: (mode: ThemeMode) => void) => () => void+}++export const LIVE_LOOK: Partial<Record<SetupChooseKind, LiveLook>> = {+ accent: {+ apply: id => {+ const hex = normalizeHex(id)- if (hex) {- setAccentOverride(hex === NOUS_ACCENT ? null : hex)+ if (hex) {+ const accent = hex === NOUS_ACCENT ? null : hex++ setOnboardingAnswers({ accent })+ setAccentOverride(accent)+ }+ },+ snapshot: () => {+ const { accent } = $onboardingAnswers.get()+ const override = $accentOverride.get()++ return () => {+ setOnboardingAnswers({ accent })+ setAccentOverride(override)+ }}},- layout: id => {- const preset = registry.getArea('layouts').find(contribution => contribution.id === id)+ layout: {+ apply: id => {+ const preset = registry.getArea('layouts').find(contribution => contribution.id === id)- if (!preset?.data) {- return- }+ if (!preset?.data) {+ return+ }- $chatLayoutPicked.set(true)- assembleChatOnboarding(preset.id, preset.data as LayoutNode, LAYOUTS.find(layout => layout.id === id)?.mode)+ $chatLayoutPicked.set(true)+ assembleChatOnboarding(preset.id, preset.data as LayoutNode, LAYOUTS.find(layout => layout.id === id)?.mode)+ },+ snapshot: snapshotChatLayout},- theme: (id, setMode) => {- if (MODE_OPTIONS.some(option => option.id === id)) {- setMode(id as ThemeMode)- }+ theme: {+ apply: (id, setMode) => {+ if (MODE_OPTIONS.some(option => option.id === id)) {+ setMode(id as ThemeMode)+ }+ },+ snapshot: (mode, setMode) => () => setMode(mode)}}diff --git a/apps/desktop/src/components/notifications.tsx b/apps/desktop/src/components/notifications.tsxindex 897f7546c84..8971db9dd40 100644--- a/apps/desktop/src/components/notifications.tsx+++ b/apps/desktop/src/components/notifications.tsx@@ -277,7 +277,7 @@ function NotificationItem({ notification, stack }: { notification: AppNotificatireturn (<Alertaria-live={!stack.active ? 'off' : notification.kind === 'error' ? 'assertive' : 'polite'}- className="grid-cols-[auto_minmax(0,1fr)_auto] border-0 bg-transparent pr-2.5 shadow-none"+ className="grid-cols-[auto_minmax(0,1fr)_auto] border-0 bg-transparent pr-2.5 text-xs shadow-none"role={notification.kind === 'error' ? 'alert' : 'status'}variant={styles.variant}>diff --git a/apps/desktop/src/components/onboarding-chat/assembly.ts b/apps/desktop/src/components/onboarding-chat/assembly.tsindex 623a9f5d0b5..bc7acdd8e21 100644--- a/apps/desktop/src/components/onboarding-chat/assembly.ts+++ b/apps/desktop/src/components/onboarding-chat/assembly.ts@@ -176,6 +176,41 @@ export function assembleChatOnboarding(id: string, tree: LayoutNode, mode?: Inte$chatOnboardingSolo.set(false)}+export function snapshotChatLayout(): () => void {+ const snapshot = {+ id: $activePresetId.get(),+ mode: $interfaceMode.get(),+ panes: $paneStates.get(),+ picked: $chatLayoutPicked.get(),+ placed: $userPlacedPanes.get(),+ previous: previousLayout,+ solo: $chatOnboardingSolo.get(),+ tree: $layoutTree.get()+ }++ return () => {+ if (snapshot.mode !== $interfaceMode.get()) {+ setInterfaceMode(snapshot.mode)+ }++ if (snapshot.tree) {+ $layoutTree.set(snapshot.tree)+ $paneStates.set(snapshot.panes)+ $userPlacedPanes.set(snapshot.placed)+ markActivePreset(snapshot.id)+ persistTree()+ }++ previousLayout = snapshot.previous+ $chatLayoutPicked.set(snapshot.picked)++ if (snapshot.solo && !$chatOnboardingSolo.get()) {+ $chatOnboardingSolo.set(true)+ window.hermesDesktop?.chatOnboarding?.soloBoot?.()+ }+ }+}+export function skipChatOnboarding(): void {const preset = registry.getArea('layouts').find(contribution => contribution.id === 'basic')diff --git a/apps/desktop/src/components/onboarding-chat/options.tsx b/apps/desktop/src/components/onboarding-chat/options.tsxindex 30c6621ae0b..af8444af0e9 100644--- a/apps/desktop/src/components/onboarding-chat/options.tsx+++ b/apps/desktop/src/components/onboarding-chat/options.tsx@@ -1,3 +1,5 @@+import type { CSSProperties } from 'react'+import { selectableClass } from '@/components/onboarding-chat/chip'import { Codicon } from '@/components/ui/codicon'import { Tip } from '@/components/ui/tooltip'@@ -170,17 +172,22 @@ export function LayoutPreviewCard({description,name,onSelect,+ previewStyle,tree}: {active: booleandescription?: stringname: stringonSelect: () => void+ previewStyle?: CSSPropertiestree: MiniNode}) {return (<button aria-pressed={active} className="group flex flex-col items-center gap-2" onClick={onSelect} type="button">- <span className={cn('flex aspect-[10/7] w-full flex-col gap-1.5 rounded-[8px] p-2', selectableClass(active))}>+ <span+ className={cn('flex aspect-[10/7] w-full flex-col gap-1.5 rounded-[8px] p-2', selectableClass(active))}+ style={previewStyle}+ ><MiniWindowButtons /><span className="flex min-h-0 flex-1"><MiniTree node={tree} />diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 018b85e002f..07b0b254e4d 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -3364,6 +3364,7 @@ export const ar = defineLocale({placeholder: 'اكتب إجابتك...',skip: 'تخطي',confirmAndContinueLabel: 'تأكيد ومتابعة',+ oneQuestion: 'سؤال واحد',questionProgress: (answered, total) => `تمت الإجابة على ${answered} من ${total}`},setupChoose: {@@ -3379,6 +3380,10 @@ export const ar = defineLocale({findApp: 'ابحث عن تطبيق',customColor: 'لون مخصص',plugin: 'إضافة',+ nothingYet: {+ lead: 'لن يتم ربط أو تثبيت أي شيء بعد.',+ rest: 'سيعرض Hermes ربط هذه أو تثبيت إضافة عندما تحتاجها مهمة ما، ويسأل أولًا.'+ },intent: { now: 'الآن', later: 'عند الحاجة', save: 'دوّنها فقط' }},startChat: {diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 8822b6ae7f3..e5f6fb85e17 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -5715,6 +5715,7 @@ export const deOverrides = {skipped: 'Übersprungen',noAnswer: 'Keine Antwort',confirmAndContinueLabel: 'Bestätigen und fortfahren',+ oneQuestion: '1 Frage',questionProgress: (answered, total) => `${answered} von ${total} beantwortet`,notDelivered:'Diese Frage hat die App nicht erreicht und kann hier nicht beantwortet werden. Klicken Sie auf Stopp, um den Durchgang zu beenden, und antworten Sie dann im Chat.'@@ -5732,6 +5733,10 @@ export const deOverrides = {findApp: 'App suchen',customColor: 'Eigene Farbe',plugin: 'Plugin',+ nothingYet: {+ lead: 'Noch wird nichts verbunden oder installiert.',+ rest: 'Hermes bietet an, diese zu verknüpfen oder ein Plugin zu installieren, wenn eine Aufgabe sie braucht, und fragt vorher.'+ },intent: { now: 'Jetzt', later: 'Bei Bedarf', save: 'Nur merken' }},startChat: {diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex cc2a3849e74..b3cd31d681b 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -5320,6 +5320,7 @@ export const en: Translations = {skipped: 'Skipped',noAnswer: 'No answer',confirmAndContinueLabel: 'Confirm and continue',+ oneQuestion: '1 question',questionProgress: (answered, total) => `${answered} of ${total} answered`,notDelivered:"This question didn't reach the app, so it can't be answered here. Press Stop to end the turn, then reply in chat."@@ -5337,6 +5338,10 @@ export const en: Translations = {findApp: 'Find an app',customColor: 'Custom color',plugin: 'Plugin',+ nothingYet: {+ lead: 'Nothing connects or installs yet.',+ rest: 'Hermes will offer to link these, or install a plugin, when a task needs them, and asks first.'+ },intent: { now: 'Now', later: 'When needed', save: 'Just note it' }},startChat: {diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 4e2d170746f..39a7e121e01 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -5708,6 +5708,7 @@ export const esOverrides = {skipped: 'Omitido',noAnswer: 'Sin respuesta',confirmAndContinueLabel: 'Confirmar y continuar',+ oneQuestion: '1 pregunta',questionProgress: (answered, total) => `${answered} de ${total} respondidas`,notDelivered:'Esta pregunta no llegó a la app, así que no se puede responder aquí. Pulsa Detener para terminar el turno y luego responde en el chat.'@@ -5725,6 +5726,10 @@ export const esOverrides = {findApp: 'Buscar una app',customColor: 'Color personalizado',plugin: 'Plugin',+ nothingYet: {+ lead: 'Todavía no se conecta ni se instala nada.',+ rest: 'Hermes ofrecerá vincularlos o instalar un plugin cuando una tarea los necesite, y pregunta antes.'+ },intent: { now: 'Ahora', later: 'Cuando haga falta', save: 'Solo anotarlo' }},startChat: {diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex f5c80a2c0ba..14ce9c02ee2 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -5729,6 +5729,7 @@ export const frOverrides = {skipped: 'Ignoré',noAnswer: 'Pas de réponse',confirmAndContinueLabel: 'Confirmer et continuer',+ oneQuestion: '1 question',questionProgress: (answered, total) => `${answered} réponse${answered === 1 ? '' : 's'} sur ${total}`,notDelivered:"Cette question n'a pas atteint l'app, elle ne peut donc pas être répondue ici. Appuyez sur Arrêter pour terminer le tour, puis répondez dans le chat."@@ -5746,6 +5747,10 @@ export const frOverrides = {findApp: 'Trouver une app',customColor: 'Couleur personnalisée',plugin: 'Plugin',+ nothingYet: {+ lead: 'Rien n’est connecté ni installé pour l’instant.',+ rest: 'Hermes proposera de les relier, ou d’installer un plugin, quand une tâche en aura besoin, et demandera d’abord.'+ },intent: { now: 'Maintenant', later: 'Au besoin', save: 'Juste noter' }},startChat: {diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 443287355ed..a23d3ca5722 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -3935,6 +3935,7 @@ export const ja = defineLocale({skipped: 'スキップ済み',noAnswer: '回答なし',confirmAndContinueLabel: '確定して続行',+ oneQuestion: '1問',questionProgress: (answered, total) => `${total}問中${answered}問回答済み`,notDelivered:'この質問はアプリに届かなかったため、ここでは回答できません。停止を押してターンを終了し、チャットで返信してください。'@@ -3952,6 +3953,10 @@ export const ja = defineLocale({findApp: 'アプリを検索',customColor: 'カスタムカラー',plugin: 'プラグイン',+ nothingYet: {+ lead: 'まだ何も接続・インストールされません。',+ rest: 'タスクで必要になったとき、Hermes がこれらの連携やプラグインのインストールを提案し、先に確認します。'+ },intent: { now: '今すぐ', later: '必要なときに', save: 'メモだけ' }},startChat: {diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 72e523a23bc..d4033bc3005 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -4057,6 +4057,7 @@ export const ru = defineLocale({skipped: 'Пропущено',noAnswer: 'Нет ответа',confirmAndContinueLabel: 'Подтвердить и продолжить',+ oneQuestion: '1 вопрос',questionProgress: (answered, total) => `Ответ дан на ${answered} из ${total}`,notDelivered:'Этот вопрос не дошёл до приложения, поэтому ответить здесь нельзя. Нажмите «Стоп», чтобы завершить ход, и ответьте в чате.'@@ -4074,6 +4075,10 @@ export const ru = defineLocale({findApp: 'Найти приложение',customColor: 'Свой цвет',plugin: 'Плагин',+ nothingYet: {+ lead: 'Пока ничего не подключается и не устанавливается.',+ rest: 'Hermes предложит подключить их или установить плагин, когда это понадобится для задачи, и сначала спросит.'+ },intent: { now: 'Сейчас', later: 'Когда понадобится', save: 'Просто запомнить' }},startChat: {diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 5fa7193a7f0..e667af48e21 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -4429,6 +4429,7 @@ export interface Translations {skipped: stringnoAnswer: stringconfirmAndContinueLabel: string+ oneQuestion: stringquestionProgress: (answered: number, total: number) => stringnotDelivered: string}@@ -4439,6 +4440,7 @@ export interface Translations {findApp: stringcustomColor: stringplugin: string+ nothingYet: { lead: string; rest: string }intent: Record<'later' | 'now' | 'save', string>}startChat: {diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 969cefc6eda..c4add8a9af0 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -4099,6 +4099,7 @@ export const zhHant = defineLocale({skipped: '已略過',noAnswer: '未回答',confirmAndContinueLabel: '確認並繼續',+ oneQuestion: '1 個問題',questionProgress: (answered, total) => `已回答 ${answered}/${total}`,notDelivered: '此問題未送達應用程式,無法在此回答。請按停止結束本輪,然後在聊天中回覆。'},@@ -4115,6 +4116,10 @@ export const zhHant = defineLocale({findApp: '尋找應用程式',customColor: '自訂顏色',plugin: '外掛',+ nothingYet: {+ lead: '目前不會連接或安裝任何東西。',+ rest: '當任務需要時,Hermes 會提議連結這些項目或安裝外掛,並先徵求你的同意。'+ },intent: { now: '現在', later: '需要時', save: '僅記下' }},startChat: {diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex e4d48d9695e..c8c41acca39 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -4889,6 +4889,7 @@ export const zh = defineLocale({skipped: '已跳过',noAnswer: '未回答',confirmAndContinueLabel: '确认并继续',+ oneQuestion: '1 个问题',questionProgress: (answered, total) => `已回答 ${answered}/${total}`,notDelivered: '此问题未送达应用,无法在此回答。请按停止结束本轮,然后在聊天中回复。'},@@ -4905,6 +4906,10 @@ export const zh = defineLocale({findApp: '查找应用',customColor: '自定义颜色',plugin: '插件',+ nothingYet: {+ lead: '目前不会连接或安装任何东西。',+ rest: '当任务需要时,Hermes 会提议关联这些项目或安装插件,并先征求你的同意。'+ },intent: { now: '现在', later: '需要时', save: '仅记下' }},startChat: {diff --git a/apps/desktop/src/store/clarify.ts b/apps/desktop/src/store/clarify.tsindex 6cd4b9d1e4e..fdddc5e55fb 100644--- a/apps/desktop/src/store/clarify.ts+++ b/apps/desktop/src/store/clarify.ts@@ -1,4 +1,4 @@-import type { SetupChooseKind, SetupChooseOption } from '@hermes/shared'+import type { SetupChooseIntent, SetupChooseKind, SetupChooseOption } from '@hermes/shared'import { atom, computed } from 'nanostores'import { hasOpenServerRequest, respondToServerRequest } from './server-requests'@@ -205,6 +205,41 @@ export function clearClarifyRequest(requestId?: string, sessionId?: string | nul}}+export interface SetupChooseStage {+ draft: string+ intents: Record<string, SetupChooseIntent>+ picked: string[]+ revert: (() => void) | null+}++export const EMPTY_SETUP_STAGE: SetupChooseStage = { draft: '', intents: {}, picked: [], revert: null }++export const $setupChooseStages = atom<Record<string, SetupChooseStage>>({})++export const setupChooseStage = (requestId: string): SetupChooseStage =>+ $setupChooseStages.get()[requestId] ?? EMPTY_SETUP_STAGE++export function stageSetupChoose(requestId: string, patch: Partial<SetupChooseStage>): void {+ $setupChooseStages.set({ ...$setupChooseStages.get(), [requestId]: { ...setupChooseStage(requestId), ...patch } })+}++export function commitSetupChoose(requestId: string): void {+ const next = { ...$setupChooseStages.get() }+ delete next[requestId]+ $setupChooseStages.set(next)+}++$clarifyRequests.listen(requests => {+ const live = new Set(Object.values(requests).map(request => request.requestId))++ for (const [requestId, stage] of Object.entries($setupChooseStages.get())) {+ if (!live.has(requestId)) {+ commitSetupChoose(requestId)+ stage.revert?.()+ }+ }+})+/** Whether `sessionId` has a clarify parked on it right now (imperative read —* the composer checks this on Enter, not on every render). */export const hasClarifyRequest = (sessionId: string | null | undefined): boolean =>diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex 074e1731f10..047c22ba7c8 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -135,6 +135,7 @@"assistant.clarify.noAnswer","assistant.clarify.notDelivered","assistant.clarify.notReady",+ "assistant.clarify.oneQuestion","assistant.clarify.other","assistant.clarify.placeholder","assistant.clarify.questionProgress",@@ -167,6 +168,8 @@"assistant.setupChoose.kinds.plugins","assistant.setupChoose.kinds.theme","assistant.setupChoose.loading",+ "assistant.setupChoose.nothingYet.lead",+ "assistant.setupChoose.nothingYet.rest","assistant.setupChoose.plugin","assistant.setupChoose.unavailable","assistant.startChat.inProfile",