Skip to content

Commit 69e38fb

Browse files
committed
feat: introduce prompt library and navigation enhancements
- Added a new 'Prompts' view with a dedicated prompt library component. - Integrated prompt usage events in the agent panel for seamless interaction. - Updated sidebar and command palette to include navigation to the prompt library. - Enhanced view context to support 'prompts' as a navigable option. - Refactored settings panel to streamline its functionality and removed unused state. - Introduced new prompt templates and categories for better organization and accessibility.
1 parent 4d80809 commit 69e38fb

14 files changed

Lines changed: 2321 additions & 928 deletions

app/page.tsx

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ const WidgetPipWindow = dynamic(
7070
() => import('@/components/plugins/widget-pip-window').then((m) => m.WidgetPipWindow),
7171
{ ssr: false },
7272
)
73-
const SettingsPanel = dynamic(
74-
() => import('@/components/settings-panel').then((m) => m.SettingsPanel),
75-
{ ssr: false },
76-
)
7773
const OnboardingTour = dynamic(
7874
() => import('@/components/onboarding-tour').then((m) => m.OnboardingTour),
7975
{ ssr: false },
@@ -90,6 +86,7 @@ const VIEW_ICONS: Record<string, { icon: string; label: string }> = {
9086
diff: { icon: 'lucide:git-compare', label: 'Diff' },
9187
git: { icon: 'lucide:git-branch', label: 'Git' },
9288
skills: { icon: 'lucide:sparkles', label: 'Skills' },
89+
prompts: { icon: 'lucide:book-open', label: 'Prompts' },
9390
mcp: { icon: 'lucide:plug', label: 'MCP' },
9491
settings: { icon: 'lucide:settings', label: 'Settings' },
9592
terminal: { icon: 'lucide:terminal', label: 'Terminal' },
@@ -135,7 +132,9 @@ export default function EditorLayout() {
135132
const terminalStartupCommand = useCenteredTerminal ? 'openclaw tui' : undefined
136133
const mobileViewTabs = useMemo(() => {
137134
// On mobile, curate tabs to useful views + always include settings
138-
const mobile = visibleViews.filter((v) => !['preview', 'diff', 'skills', 'mcp'].includes(v))
135+
const mobile = visibleViews.filter(
136+
(v) => !['preview', 'diff', 'skills', 'prompts', 'mcp'].includes(v),
137+
)
139138
if (!mobile.includes('terminal')) mobile.push('terminal')
140139
return mobile.slice(0, 5)
141140
}, [visibleViews])
@@ -167,10 +166,6 @@ export default function EditorLayout() {
167166
const [globalSearchVisible, setGlobalSearchVisible] = useState(false)
168167
const [commandPaletteVisible, setCommandPaletteVisible] = useState(false)
169168
const [shortcutsVisible, setShortcutsVisible] = useState(false)
170-
const [settingsVisible, setSettingsVisible] = useState(false)
171-
const [settingsTab, setSettingsTab] = useState<
172-
'general' | 'editor' | 'agent' | 'keybindings' | 'plugins' | undefined
173-
>(undefined)
174169
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false)
175170
const [onboardingOpen, setOnboardingOpen] = useState(false)
176171

@@ -307,12 +302,10 @@ export default function EditorLayout() {
307302
useEffect(() => {
308303
const unsubs = [
309304
on('open-settings', () => {
310-
setSettingsTab(undefined)
311-
setSettingsVisible(true)
305+
setView('settings')
312306
}),
313307
on('open-agent-settings', () => {
314-
setSettingsTab('agent')
315-
setSettingsVisible(true)
308+
setView('settings')
316309
}),
317310
on('open-folder', () => localOpenFolder()),
318311
on('open-recent', (detail) => {
@@ -547,10 +540,7 @@ export default function EditorLayout() {
547540

548541
<button
549542
type="button"
550-
onClick={() => {
551-
setSettingsTab(undefined)
552-
setSettingsVisible(true)
553-
}}
543+
onClick={() => setView('settings')}
554544
className="flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border border-[var(--border)] bg-[color-mix(in_srgb,var(--bg)_92%,transparent)] text-[var(--text-secondary)] transition hover:bg-[color-mix(in_srgb,var(--text-primary)_5%,transparent)] hover:text-[var(--text-primary)]"
555545
title="Settings"
556546
>
@@ -905,6 +895,9 @@ export default function EditorLayout() {
905895
case 'view-skills':
906896
setView('skills')
907897
break
898+
case 'view-prompts':
899+
setView('prompts')
900+
break
908901
case 'find-files':
909902
setQuickOpenVisible(true)
910903
break
@@ -939,16 +932,7 @@ export default function EditorLayout() {
939932
}}
940933
/>
941934
<ShortcutsOverlay open={shortcutsVisible} onClose={() => setShortcutsVisible(false)} />
942-
{settingsVisible && activeView !== 'settings' && (
943-
<SettingsPanel
944-
open={settingsVisible}
945-
onClose={() => {
946-
setSettingsVisible(false)
947-
setSettingsTab(undefined)
948-
}}
949-
initialTab={settingsTab}
950-
/>
951-
)}
935+
952936
<OnboardingTour open={onboardingOpen} onClose={() => setOnboardingOpen(false)} />
953937
</div>
954938
)

components/agent-panel.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,14 @@ export function AgentPanel() {
830830
})
831831
}, [])
832832

833+
// ─── Listen for prompt-use events (from prompt library) ────
834+
useEffect(() => {
835+
return on('prompt-use', (detail) => {
836+
if (detail.text) setInput(detail.text)
837+
inputRef.current?.focus()
838+
})
839+
}, [])
840+
833841
// ─── Listen for focus-agent-input (⌘L from anywhere) ──────
834842
useEffect(() => {
835843
return on('focus-agent-input', () => inputRef.current?.focus())

components/chat-home.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useLocal } from '@/context/local-context'
1313
import { useGateway } from '@/context/gateway-context'
1414
import { useGitHubAuth } from '@/context/github-auth-context'
1515
import { useEditor } from '@/context/editor-context'
16+
import { useView } from '@/context/view-context'
1617
import { emit } from '@/lib/events'
1718
import { getRecentFolders } from '@/context/local-context'
1819
import { getAgentConfig } from '@/lib/agent-session'
@@ -118,6 +119,7 @@ export const ChatHome = memo(function ChatHome({
118119
const { repo, setRepo } = useRepo()
119120
const local = useLocal()
120121
const { status } = useGateway()
122+
const { setView } = useView()
121123
const { files: openFiles } = useEditor()
122124
const { token: ghToken, authenticated: ghAuthenticated } = useGitHubAuth()
123125

@@ -533,8 +535,15 @@ export const ChatHome = memo(function ChatHome({
533535
)}
534536
</div>
535537

536-
{/* "Explore more" link — desktop only */}
537-
<div className="hidden sm:flex justify-end mb-2">
538+
{/* Quick links — desktop only */}
539+
<div className="hidden sm:flex justify-end gap-4 mb-2">
540+
<button
541+
onClick={() => setView('prompts')}
542+
className="inline-flex items-center gap-1 text-[12px] text-[var(--text-disabled)] hover:text-[var(--text-secondary)] transition-colors cursor-pointer"
543+
>
544+
<Icon icon="lucide:book-open" width={11} height={11} />
545+
Browse prompt library
546+
</button>
538547
<button
539548
onClick={() => emit('open-folder')}
540549
className="text-[12px] text-[var(--text-disabled)] hover:text-[var(--text-secondary)] transition-colors cursor-pointer"

components/command-palette.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type CommandId =
3030
| 'view-preview'
3131
| 'view-git'
3232
| 'view-skills'
33+
| 'view-prompts'
3334
| 'view-settings'
3435
| 'open-onboarding'
3536
| 'open-new-window'
@@ -229,6 +230,14 @@ const COMMANDS: CommandItem[] = [
229230
icon: 'lucide:sparkles',
230231
group: 'navigate',
231232
},
233+
{
234+
id: 'view-prompts',
235+
label: 'Go to Prompt Library',
236+
hint: 'Browse curated prompt templates',
237+
keywords: ['prompts', 'templates', 'library', 'recipes'],
238+
icon: 'lucide:book-open',
239+
group: 'navigate',
240+
},
232241

233242
{
234243
id: 'open-new-window',
@@ -349,6 +358,7 @@ const VIEW_CONTEXT_COMMANDS: Partial<Record<ViewId, CommandId[]>> = {
349358
],
350359
git: ['git-commit', 'toggle-git-panel', 'git-push', 'git-pull', 'git-stash', 'toggle-terminal'],
351360
skills: ['view-skills', 'open-new-window', 'view-editor'],
361+
prompts: ['view-prompts', 'view-editor', 'open-new-window'],
352362

353363
preview: ['preview-refresh', 'view-editor'],
354364
}

0 commit comments

Comments
 (0)