From 5b8ff22d351cab27390face98964c664438d6ea8 Mon Sep 17 00:00:00 2001 From: Dawnfz-Lenfeng <2912706234@qq.com> Date: Tue, 11 Aug 2026 17:45:15 +0800 Subject: [PATCH] fix(ui): always show /init command in autocomplete The /init command was only offered in the autocomplete when the current session had no messages yet, and it was filtered out entirely once any message existed. Since the underlying session.command endpoint works in any session, keep /init available whenever a session exists so AGENTS.md setup stays reachable mid-conversation. --- .../components/chat/CommandAutocomplete.tsx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/components/chat/CommandAutocomplete.tsx b/packages/ui/src/components/chat/CommandAutocomplete.tsx index 77070181..d42ec53c 100644 --- a/packages/ui/src/components/chat/CommandAutocomplete.tsx +++ b/packages/ui/src/components/chat/CommandAutocomplete.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { cn, fuzzyMatch } from '@/lib/utils'; import { useSessionUIStore } from '@/sync/session-ui-store'; -import { useSessionMessages } from '@/sync/sync-context'; import { useCommandsStore } from '@/stores/useCommandsStore'; import { useSkillsStore } from '@/stores/useSkillsStore'; import { ScrollableOverlay } from '@/components/ui/ScrollableOverlay'; @@ -65,8 +64,6 @@ export const CommandAutocomplete = React.forwardRef { const { t } = useI18n(); const currentSessionId = useSessionUIStore((state) => state.currentSessionId); - const sessionMessages = useSessionMessages(currentSessionId ?? ''); - const hasMessagesInCurrentSession = sessionMessages.length > 0; const hasSession = Boolean(currentSessionId); const hasNewSessionDraft = useSessionUIStore((state) => Boolean(state.newSessionDraft?.open)); const canStartSessionCommand = hasSession || hasNewSessionDraft; @@ -139,7 +136,7 @@ export const CommandAutocomplete = React.forwardRef commandMatchesSearch(cmd, searchQuery)) - : allCommands).filter(cmd => allowInitCommand || cmd.name !== 'init'); + : allCommands; filtered.sort((a, b) => { const aStartsWith = a.name.toLowerCase().startsWith(searchQuery.toLowerCase()); @@ -211,9 +207,8 @@ export const CommandAutocomplete = React.forwardRef fuzzyMatch(cmd.name, searchQuery) || (cmd.description && fuzzyMatch(cmd.description, searchQuery)) ) - : builtInCommands).filter(cmd => allowInitCommand || cmd.name !== 'init'); + : builtInCommands; setCommands(filtered); } finally { @@ -282,7 +277,7 @@ export const CommandAutocomplete = React.forwardRef { setSelectedIndex(0);