Skip to content

An AI-powered search engine with a generative UI

fix: initialize search mode from cookie on component mount

Yoshiki Miurab35c2ba9826e
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index 1e151733..5932cf35 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -164,10 +164,13 @@ export function ChatPanel({
</Button>
)}
- <div className={cn(
- "relative flex flex-col w-full gap-2 bg-muted rounded-3xl border border-input transition-shadow",
- isInputFocused && "ring-1 ring-ring/20 ring-offset-1 ring-offset-background/50"
- )}>
+ <div
+ className={cn(
+ 'relative flex flex-col w-full gap-2 bg-muted rounded-3xl border border-input transition-shadow',
+ isInputFocused &&
+ 'ring-1 ring-ring/20 ring-offset-1 ring-offset-background/50'
+ )}
+ >
<Textarea
ref={inputRef}
name="input"
diff --git a/components/chat.tsx b/components/chat.tsx
index 044723c9..e58a382d 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -60,15 +60,14 @@ export function Chat({
})
const { isAuthenticated } = useAuthCheck()
- // Get search mode from cookie
- const [searchMode, setSearchMode] = useState<SearchMode>('adaptive')
-
- useEffect(() => {
+ // Get search mode from cookie - initialize with cookie value
+ const [searchMode] = useState<SearchMode>(() => {
const savedMode = getCookie('searchMode')
if (savedMode && ['quick', 'planning', 'adaptive'].includes(savedMode)) {
- setSearchMode(savedMode as SearchMode)
+ return savedMode as SearchMode
}
- }, [])
+ return 'adaptive'
+ })
const {
messages,
diff --git a/lib/agents/researcher.ts b/lib/agents/researcher.ts
index fd24a1a9..c7ff8314 100644
--- a/lib/agents/researcher.ts
+++ b/lib/agents/researcher.ts
@@ -77,9 +77,14 @@ export function researcher({
let searchTool: ReturnType<typeof createSearchTool>
// Simple switch - no config objects
+ console.log(`[Researcher] Executing in ${searchMode} mode`)
+
switch (searchMode) {
case 'quick':
// Quick Mode: Minimal tools, fast responses, optimized search only
+ console.log(
+ '[Researcher] Quick mode: maxSteps=5, tools=[search, fetch]'
+ )
systemPrompt = QUICK_MODE_PROMPT
activeToolsList = ['search', 'fetch']
maxSteps = 5
@@ -94,6 +99,9 @@ export function researcher({
if (writer && 'todoWrite' in todoTools) {
activeToolsList.push('todoWrite', 'todoRead')
}
+ console.log(
+ `[Researcher] Planning mode: maxSteps=30, tools=[${activeToolsList.join(', ')}]`
+ )
maxSteps = 30
searchTool = originalSearchTool
break
@@ -106,6 +114,9 @@ export function researcher({
if (writer && 'todoWrite' in todoTools) {
activeToolsList.push('todoWrite', 'todoRead')
}
+ console.log(
+ `[Researcher] Adaptive mode: maxSteps=20, tools=[${activeToolsList.join(', ')}]`
+ )
maxSteps = 20
searchTool = originalSearchTool
break
diff --git a/lib/config/model-types.ts b/lib/config/model-types.ts
index 9ca1895c..a6ca0beb 100644
--- a/lib/config/model-types.ts
+++ b/lib/config/model-types.ts
@@ -4,26 +4,24 @@ import { Model } from '@/lib/types/models'
// Model configurations for each model type
export const MODEL_TYPE_CONFIGS: Record<ModelType, Model> = {
speed: {
- id: 'gpt-5-nano-2025-08-07',
- name: 'GPT-5 nano',
- provider: 'OpenAI',
- providerId: 'openai',
+ id: 'moonshotai/kimi-k2',
+ name: 'Kimi K2',
+ provider: 'Vercel AI Gateway',
+ providerId: 'gateway',
providerOptions: {
- openai: {
- reasoningEffort: 'low',
- reasoningSummary: 'detailed'
+ gateway: {
+ order: ['groq', 'deepinfra']
}
}
},
quality: {
- id: 'gpt-5-2025-08-07',
- name: 'GPT-5',
- provider: 'OpenAI',
- providerId: 'openai',
+ id: 'anthropic/claude-sonnet-4',
+ name: 'Claude Sonnet 4',
+ provider: 'Vercel AI Gateway',
+ providerId: 'gateway',
providerOptions: {
- openai: {
- reasoningEffort: 'low',
- reasoningSummary: 'detailed'
+ gateway: {
+ order: ['anthropic', 'bedrock', 'vertext']
}
}
}