Skip to content

Commit 7ed65bc

Browse files
committed
feat(home): add template import option to workflow selector
Add a new option to import templates from GitHub in the workflow template selector dialog. This enhances user experience by allowing direct template imports without leaving the interface.
1 parent ecaeee8 commit 7ed65bc

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/cli/tui/routes/home/hooks/use-home-commands.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ export function useHomeCommands(options: UseHomeCommandsOptions) {
9696
const { getAvailableTemplates, selectTemplateByNumber } = await import("../../../../commands/templates.command.js")
9797

9898
const templates = await getAvailableTemplates()
99-
const options = templates.map((t, index) => {
99+
const IMPORT_ACTION = "__IMPORT_TEMPLATE__"
100+
101+
const templateOptions = templates.map((t, index) => {
100102
// Extract source from description like "5 step(s) - file.js [bmad]"
101103
const sourceMatch = t.description?.match(/\[([^\]]+)\]$/)
102104
const source = sourceMatch?.[1]
@@ -108,16 +110,35 @@ export function useHomeCommands(options: UseHomeCommandsOptions) {
108110
title: t.title,
109111
value: index + 1,
110112
description: steps ? `${steps} steps` : undefined,
111-
category: source ? "Imported" : "Core",
113+
category: source ? "Imported" : "Builtin",
112114
}
113115
})
114116

117+
// Add import option at the top (no category)
118+
const selectOptions = [
119+
{
120+
title: "⬇ Import template from GitHub",
121+
value: IMPORT_ACTION,
122+
},
123+
...templateOptions,
124+
]
125+
115126
dialog.show(() => (
116127
<DialogSelect
117128
title="Select Workflow Template"
118-
options={options}
129+
options={selectOptions}
119130
placeholder="Search templates..."
120-
onSelect={async (templateNumber: number) => {
131+
onSelect={async (selection: number | string) => {
132+
// Handle import action
133+
if (selection === IMPORT_ACTION) {
134+
dialog.close()
135+
await new Promise((resolve) => setTimeout(resolve, 100))
136+
await handleImportCommand()
137+
return
138+
}
139+
140+
// Handle template selection
141+
const templateNumber = selection as number
121142
dialog.close()
122143
try {
123144
const selectedTemplate = templates[templateNumber - 1]

0 commit comments

Comments
 (0)