import { useState, useEffect, useMemo } from "react";
import { bridge } from "@/services";
export interface WelcomeHint {
title: string;
description: string;
slashCommand?: string;
component?: React.ReactNode;
}
function ShortcutRow({ kbd, children }: { kbd: string; children: React.ReactNode }) {
return (
{kbd}
{children}
);
}
function ShortcutGuide() {
return (
⚡ Commands
View all commands
Scan project and generate AGENTS.md file
Trim context so that I focus on the essentials
💡 Tips
Browse input history
Add/Search files to reference
Add selected code directly from editor
🚀 Pro Tips
• Use YOLO mode to auto-approve tool calls
• AGENTS.md helps me understand your codebase
• Enable Thinking for complex tasks
);
}
const HINT_FIRST_TIME: WelcomeHint = {
title: "Quick Start Guide",
description: "",
component: ,
};
const HINT_AGENT_MD: WelcomeHint = {
title: "Let me map your codebase",
description: "Run /init to scan the project and generate docs",
slashCommand: "/init",
};
const HINTS_POOL: WelcomeHint[] = [
HINT_FIRST_TIME,
HINT_AGENT_MD,
{
title: "Reference specific code",
description: "Type @ to select files, or press Alt+K with code highlighted",
},
{
title: "See what I can do",
description: "Type / for all commands—like /compact to trim context",
},
{
title: "Need deeper analysis?",
description: "Enable thinking mode for complex architecture or debugging",
},
{
title: "More than code",
description: "Paste a screenshot or design and I'll help implement it",
},
{
title: "Add more tools",
description: "Connect external services via MCP servers in settings",
},
{
title: "Prefer fewer interruptions?",
description: "Enable YOLO mode to auto-approve",
},
{
title: "Context getting long?",
description: "Type /compact to keep only the essentials",
slashCommand: "/compact",
},
];
function pickRandom(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)];
}
function withProbability(p: number): boolean {
return Math.random() < p;
}
export function useWelcomeHint(): WelcomeHint {
const [hasAgentMd, setHasAgentMd] = useState(null);
const [hasHistory, setHasHistory] = useState(null);
useEffect(() => {
bridge
.checkFileExists("AGENT.md")
.then(setHasAgentMd)
.catch(() => setHasAgentMd(false));
bridge
.getKimiSessions()
.then((s) => setHasHistory(s.length > 0))
.catch(() => setHasHistory(false));
}, []);
return useMemo(() => {
// First time user: show shortcut guide
if (hasHistory === false) {
return HINT_FIRST_TIME;
}
// 30% chance to show AGENT.md hint if missing
if (hasAgentMd === false && withProbability(0.3)) {
return HINT_AGENT_MD;
}
return pickRandom(HINTS_POOL);
}, [hasAgentMd, hasHistory]);
}