The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): slash commands wait until onboarding setup ends
alt-glitch70c97f9113a2
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsxindex d929e041de6..9fba46206e0 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx@@ -13,6 +13,7 @@ import {import { $queuedPromptsBySession, clearQueuedPrompts, getQueuedPrompts } from '@/store/composer-queue'import { $connectionRequests, type ConnectionRequest } from '@/store/connection-request'import { $gateway } from '@/store/gateway'+import { $notifications } from '@/store/notifications'import { $onboardingPhase } from '@/store/onboarding-phase'import { $onboardingSession } from '@/store/onboarding-session'import {@@ -1024,4 +1025,37 @@ describe('useComposerSubmit with a setup card waiting in the onboarding chat', (expect(onSteer).not.toHaveBeenCalled()expect(onSubmit).not.toHaveBeenCalled()})++ it('runs no slash command while setup is in progress: the words stay and a note says why', () => {+ $onboardingPhase.set('shown')+ $onboardingSession.set({ connectionId: null, runId: 'run-1', runtimeId: 'runtime-session', storedId: 'stored-session' })+ $notifications.set([])+ const respond = parkCard('name')++ for (const busy of [false, true]) {+ const { clearDraft, hook, onSubmit, queueCurrentDraft } = renderSubmitHook({ busy, text: '/help' })++ act(() => hook.result.current.submitDraft())++ expect(onSubmit).not.toHaveBeenCalled()+ expect(queueCurrentDraft).not.toHaveBeenCalled()+ expect(clearDraft).not.toHaveBeenCalled()+ cleanup()+ }++ expect(respond).not.toHaveBeenCalled()+ // One note, however often Enter is pressed.+ expect($notifications.get().map(note => note.kind)).toEqual(['info'])+ })++ it('runs slash commands as usual in the same chat once setup has ended', () => {+ $onboardingPhase.set('done')+ $onboardingSession.set({ connectionId: null, runId: 'run-1', runtimeId: 'runtime-session', storedId: 'stored-session' })++ const { hook, onSubmit } = renderSubmitHook({ text: '/help' })++ act(() => hook.result.current.submitDraft())++ expect(onSubmit).toHaveBeenCalledWith('/help', expect.anything())+ })})diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.tsindex c9ad1304796..dc63974f434 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts@@ -19,6 +19,7 @@ import { resetBrowseState } from '@/store/composer-input-history'import { enqueueQueuedPrompt, type QueuedPromptEntry, serverOwnsComposerQueue } from '@/store/composer-queue'import { hasConnectionRequest, skipConnectionRequest } from '@/store/connection-request'import { notify } from '@/store/notifications'+import { isOnboardingChat } from '@/store/onboarding-session'import { answerParkedCard, skipParkedCards, yieldParkedCardsToMessage } from '@/store/parked-card-answers'import { hasBlockingPromptRequest } from '@/store/prompts'@@ -394,6 +395,14 @@ export function useComposerSubmit({const text = pathifyRefs(draftRef.current)const payloadPresent = text.trim().length > 0 || attachments.length > 0+ // Slash commands come after setup: the words stay put, and one note (re-shown, never stacked) says why.+ if (isSlashCommandText(text) && isOnboardingChat(sessionId)) {+ notify({ id: 'onboarding-slash-off', kind: 'info', message: t.firstRun.slashOffBody, title: t.firstRun.slashOffTitle })+ focusInput()++ return+ }+const parked = answerParkedCardWithDraft(text, payloadPresent)if (parked === 'answered') {diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.test.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.test.tsindex fd8599d7460..bab3d62b8d8 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.test.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.test.ts@@ -47,7 +47,7 @@ const item = (command: string, group = 'Skills'): Unstable_TriggerItem => ({metadata: { command, display: command, meta: '', group, action: '', rawText: command }})-function mountTrigger(editor: HTMLDivElement, items: Unstable_TriggerItem[]) {+function mountTrigger(editor: HTMLDivElement, items: Unstable_TriggerItem[], slashOff = false) {const editorRef = createRef<HTMLDivElement>() as { current: HTMLDivElement | null }editorRef.current = editor@@ -68,13 +68,28 @@ function mountTrigger(editor: HTMLDivElement, items: Unstable_TriggerItem[]) {editorRef,requestMainFocus: vi.fn(),setComposerText,- slash: { adapter, loading: false }+ slash: { adapter, loading: false, off: slashOff }}))return { draftRef, hook, setComposerText }}+describe('useComposerTrigger — the onboarding chat before setup ends', () => {+ it('opens no slash menu, and still opens the @ menu', () => {+ const { hook } = mountTrigger(mountEditor('/hel'), [item('/help')], true)++ act(() => hook.result.current.refreshTrigger())+ expect(hook.result.current.trigger).toBeNull()+ expect(hook.result.current.triggerItems).toHaveLength(0)++ const at = mountTrigger(mountEditor('look at @Desktop/'), [], true)++ act(() => at.hook.result.current.refreshTrigger())+ expect(at.hook.result.current.trigger).toMatchObject({ kind: '@' })+ })+})+describe('useComposerTrigger — slash anywhere in the prompt', () => {it('opens the completion list for a slash typed mid-message', () => {const editor = mountEditor('please run /cle')diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.tsindex a6c5c898aff..e5b7e234003 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-trigger.ts@@ -88,6 +88,8 @@ export function rebuildAroundCaret(editor: HTMLDivElement, tokenLength: number,interface CompletionSource {adapter: Unstable_TriggerAdapter | nullloading: boolean+ /** Opens no menu: `/` in the onboarding chat before its setup ends. */+ off?: boolean}interface UseComposerTriggerOptions {@@ -144,6 +146,8 @@ export function useComposerTrigger({setTriggerActiveExplicit(false)}, [])+ const slashOff = Boolean(slash.off)+const refreshTrigger = useCallback(() => {const editor = editorRef.current@@ -168,7 +172,8 @@ export function useComposerTrigger({}const before = textBeforeCaret(editor)- const found = detectTrigger(before ?? composerPlainText(editor))+ const typed = detectTrigger(before ?? composerPlainText(editor))+ const found = slashOff && typed?.kind === '/' ? null : typed// A text-only command has no completion screen once its prose begins. Mixed// commands such as /goal stay live so their finite subcommands can still be@@ -192,7 +197,7 @@ export function useComposerTrigger({if (detected?.kind !== trigger?.kind || detected?.query !== trigger?.query) {resetTriggerActive()}- }, [editorRef, resetTriggerActive, trigger])+ }, [editorRef, resetTriggerActive, slashOff, trigger])const triggerAdapter: Unstable_TriggerAdapter | null =trigger?.kind === '@'diff --git a/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts b/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.tsindex a6102dfde21..533fbf76169 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts@@ -19,6 +19,7 @@ import {} from '@/lib/desktop-slash-commands'import { $slashCompletionsEpoch, cachedSlashCompletion, hasCachedSlashCompletion } from '@/lib/slash-completion-cache'import { normalize } from '@/lib/text'+import { onboardingChatStore } from '@/store/onboarding-session'import { $sessions } from '@/store/session'import { completionOwner, completionOwnerKey, requestCompletion } from './completion-route'@@ -57,6 +58,13 @@ function commandText(value: string): string {/** How many recent sessions to surface inline before the "Browse all…" entry. */const SESSION_INLINE_LIMIT = 7+export interface SlashCompletions {+ adapter: Unstable_TriggerAdapter+ loading: boolean+ /** No `/` menu for this session: the onboarding chat before its setup ends. */+ off: boolean+}+/** Live `/` completions backed by the gateway's `complete.slash` RPC. */export function useSlashCompletions(options: {gateway: HermesGateway | null@@ -70,10 +78,7 @@ export function useSlashCompletions(options: {* come from here, not the backend (whose skin list is CLI/TUI-only). */skinThemes?: DesktopThemeCommandOption[]activeSkin?: string-}): {- adapter: Unstable_TriggerAdapter- loading: boolean-} {+}): SlashCompletions {const { gateway, sessionId, profile, skinThemes, activeSkin } = optionsconst { locale } = useI18n()const enabled = Boolean(gateway)@@ -350,5 +355,9 @@ export function useSlashCompletions(options: {[skinThemes, keysFor])- return useLiveCompletionAdapter({ enabled, epoch: `${epoch}:${locale}`, fetcher, isCached, toItem })+ const live = useLiveCompletionAdapter({ enabled, epoch: `${epoch}:${locale}`, fetcher, isCached, toItem })+ // Slash commands come after setup: none in the onboarding chat until its run ends.+ const off = useStore(useMemo(() => onboardingChatStore(sessionId ?? null), [sessionId]))++ return { ...live, off }}diff --git a/apps/desktop/src/i18n/ar_first_run.ts b/apps/desktop/src/i18n/ar_first_run.tsindex 797f340164c..beb773d893b 100644--- a/apps/desktop/src/i18n/ar_first_run.ts+++ b/apps/desktop/src/i18n/ar_first_run.ts@@ -28,6 +28,8 @@ export const arFirstRun: FirstRunCopy = {skip: 'تخطي الإعداد',skipTip: 'إنهاء الإعداد الموجَّه وفتح محادثة جديدة.',skipFailed: 'تعذّر تخطي الإعداد',+ slashOffTitle: 'أوامر الشرطة المائلة غير متاحة أثناء الإعداد',+ slashOffBody: 'ستعمل كالمعتاد بعد انتهاء الإعداد.',localModel: {title: 'يمكن لهذا الكمبيوتر تشغيل نموذج محليًا',text: (model, size) => `${model} (${size}) يناسب أجهزتك. يعمل مجانًا، وتبقى محادثاتك على هذا الكمبيوتر.`,diff --git a/apps/desktop/src/i18n/de_first_run.ts b/apps/desktop/src/i18n/de_first_run.tsindex 4a07285cfd1..efa93b2cf69 100644--- a/apps/desktop/src/i18n/de_first_run.ts+++ b/apps/desktop/src/i18n/de_first_run.ts@@ -28,6 +28,8 @@ export const deFirstRun: FirstRunCopy = {skip: 'Einrichtung überspringen',skipTip: 'Beendet die geführte Einrichtung und öffnet einen neuen Chat.',skipFailed: 'Einrichtung konnte nicht übersprungen werden',+ slashOffTitle: 'Slash-Befehle sind während der Einrichtung aus',+ slashOffBody: 'Nach der Einrichtung funktionieren sie wie gewohnt.',localModel: {title: 'Dieser Computer kann ein Modell lokal ausführen',text: (model, size) =>diff --git a/apps/desktop/src/i18n/en_first_run.ts b/apps/desktop/src/i18n/en_first_run.tsindex 2b00a81a576..d0be61363da 100644--- a/apps/desktop/src/i18n/en_first_run.ts+++ b/apps/desktop/src/i18n/en_first_run.ts@@ -28,6 +28,8 @@ export const enFirstRun: FirstRunCopy = {skip: 'Skip setup',skipTip: 'End the guided setup and open a new chat.',skipFailed: 'Could not skip setup',+ slashOffTitle: 'Slash commands are off during setup',+ slashOffBody: 'They work as usual once setup is done.',localModel: {title: 'This computer can run a model locally',text: (model, size) => `${model} (${size}) fits your hardware. It runs free, and your chats stay on this computer.`,diff --git a/apps/desktop/src/i18n/es_first_run.ts b/apps/desktop/src/i18n/es_first_run.tsindex a7bd11f3668..5017c879047 100644--- a/apps/desktop/src/i18n/es_first_run.ts+++ b/apps/desktop/src/i18n/es_first_run.ts@@ -28,6 +28,8 @@ export const esFirstRun: FirstRunCopy = {skip: 'Omitir configuración',skipTip: 'Termina la configuración guiada y abre un chat nuevo.',skipFailed: 'No se pudo omitir la configuración',+ slashOffTitle: 'Los comandos con barra no están disponibles durante la configuración',+ slashOffBody: 'Funcionarán con normalidad cuando termine la configuración.',localModel: {title: 'Este ordenador puede ejecutar un modelo localmente',text: (model, size) =>diff --git a/apps/desktop/src/i18n/fr_first_run.ts b/apps/desktop/src/i18n/fr_first_run.tsindex 969f681aeb4..0d2b62e8114 100644--- a/apps/desktop/src/i18n/fr_first_run.ts+++ b/apps/desktop/src/i18n/fr_first_run.ts@@ -28,6 +28,8 @@ export const frFirstRun: FirstRunCopy = {skip: 'Ignorer la configuration',skipTip: 'Termine la configuration guidée et ouvre une nouvelle discussion.',skipFailed: 'Impossible d’ignorer la configuration',+ slashOffTitle: 'Les commandes slash sont désactivées pendant la configuration',+ slashOffBody: 'Elles fonctionneront normalement une fois la configuration terminée.',localModel: {title: 'Cet ordinateur peut exécuter un modèle en local',text: (model, size) =>diff --git a/apps/desktop/src/i18n/ja_first_run.ts b/apps/desktop/src/i18n/ja_first_run.tsindex dce444dfcd2..3ad12518684 100644--- a/apps/desktop/src/i18n/ja_first_run.ts+++ b/apps/desktop/src/i18n/ja_first_run.ts@@ -28,6 +28,8 @@ export const jaFirstRun: FirstRunCopy = {skip: 'セットアップをスキップ',skipTip: 'ガイド付きセットアップを終了し、新しいチャットを開きます。',skipFailed: 'セットアップをスキップできませんでした',+ slashOffTitle: 'セットアップ中はスラッシュコマンドを使えません',+ slashOffBody: 'セットアップが終わると通常どおり使えます。',localModel: {title: 'このコンピューターはモデルをローカルで実行できます',text: (model, size) =>diff --git a/apps/desktop/src/i18n/ru_first_run.ts b/apps/desktop/src/i18n/ru_first_run.tsindex ab068879767..198ddedb560 100644--- a/apps/desktop/src/i18n/ru_first_run.ts+++ b/apps/desktop/src/i18n/ru_first_run.ts@@ -28,6 +28,8 @@ export const ruFirstRun: FirstRunCopy = {skip: 'Пропустить настройку',skipTip: 'Завершить пошаговую настройку и открыть новый чат.',skipFailed: 'Не удалось пропустить настройку',+ slashOffTitle: 'Во время настройки слэш-команды недоступны',+ slashOffBody: 'После настройки они будут работать как обычно.',localModel: {title: 'Этот компьютер может запускать модель локально',text: (model, size) =>diff --git a/apps/desktop/src/i18n/types_first_run.ts b/apps/desktop/src/i18n/types_first_run.tsindex eb24e10569b..2e850da997a 100644--- a/apps/desktop/src/i18n/types_first_run.ts+++ b/apps/desktop/src/i18n/types_first_run.ts@@ -33,6 +33,9 @@ export interface FirstRunCopy {skip: stringskipTip: stringskipFailed: string+ /** A slash command sent in the onboarding chat before setup ends: it does not run. */+ slashOffTitle: string+ slashOffBody: stringlocalModel: {title: stringtext: (model: string, size: string) => stringdiff --git a/apps/desktop/src/i18n/zh-hant_first_run.ts b/apps/desktop/src/i18n/zh-hant_first_run.tsindex 85be5066334..7c161fcb67a 100644--- a/apps/desktop/src/i18n/zh-hant_first_run.ts+++ b/apps/desktop/src/i18n/zh-hant_first_run.ts@@ -28,6 +28,8 @@ export const zhHantFirstRun: FirstRunCopy = {skip: '略過設定',skipTip: '結束引導設定並開啟新對話。',skipFailed: '無法略過設定',+ slashOffTitle: '設定期間無法使用斜線指令',+ slashOffBody: '設定完成後即可照常使用。',localModel: {title: '這部電腦可以在本機執行模型',text: (model, size) => `${model}(${size})適合你的硬體。它免費執行,你的對話會留在這部電腦上。`,diff --git a/apps/desktop/src/i18n/zh_first_run.ts b/apps/desktop/src/i18n/zh_first_run.tsindex 24b37e05064..c2448ce1815 100644--- a/apps/desktop/src/i18n/zh_first_run.ts+++ b/apps/desktop/src/i18n/zh_first_run.ts@@ -28,6 +28,8 @@ export const zhFirstRun: FirstRunCopy = {skip: '跳过设置',skipTip: '结束引导设置并打开新对话。',skipFailed: '无法跳过设置',+ slashOffTitle: '设置期间无法使用斜杠命令',+ slashOffBody: '设置完成后即可照常使用。',localModel: {title: '这台电脑可以在本地运行模型',text: (model, size) => `${model}(${size})适合你的硬件。它免费运行,你的对话会留在这台电脑上。`,diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex 5632e2ce173..4fc576b0bac 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -1643,6 +1643,8 @@"firstRun.skipFailed","firstRun.skipTip","firstRun.skippedAll",+ "firstRun.slashOffBody",+ "firstRun.slashOffTitle","firstRun.tours.full","firstRun.tours.quick","firstRun.tours.skip",