Skip to content

Commit 1d825af

Browse files
committed
feat(ui): add Configuration UI integration for newTerminal option
Add UI support for newTerminal core feature added. - Add i18n translation keys (en.json, ko.json) - Add checkbox UI to command-form.tsx (shown only in Terminal mode) - Add checkbox for single commands within groups in group-command-item.tsx - Add newTerminal field to Zod schemas and type definitions - Fix missing newTerminal field in ensure-id.ts data transformation - Fix missing newTerminal field in webview-provider.ts Zod validation schema fix #246
1 parent 435adc3 commit 1d825af

File tree

8 files changed

+49
-10
lines changed

8 files changed

+49
-10
lines changed

src/internal/providers/webview-provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const buttonConfigWithOptionalIdSchema: z.ZodSchema = z.lazy(() =>
9191
id: z.string().optional(),
9292
insertOnly: z.boolean().optional(),
9393
name: z.string(),
94+
newTerminal: z.boolean().optional(),
9495
shortcut: z.string().optional(),
9596
terminalName: z.string().optional(),
9697
useVsCodeApi: z.boolean().optional(),

src/internal/utils/ensure-id.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const ensureId = (config: ButtonConfigWithOptionalId): ButtonConfig => {
3737
id,
3838
insertOnly: config.insertOnly,
3939
name: config.name,
40+
newTerminal: config.newTerminal,
4041
shortcut: config.shortcut,
4142
terminalName: config.terminalName,
4243
useVsCodeApi: config.useVsCodeApi,

src/view/src/components/command-form.tsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const createDefaultValues = (command?: ButtonConfig | null): ButtonConfigDraft =
5252
id: crypto.randomUUID(),
5353
insertOnly: false,
5454
name: "",
55+
newTerminal: false,
5556
shortcut: "",
5657
terminalName: "",
5758
useVsCodeApi: false,
@@ -62,6 +63,7 @@ const buildCommandConfig = (data: ButtonConfigDraft, isGroup: boolean): ButtonCo
6263
...data,
6364
color: data.color || undefined,
6465
name: data.name.trim(),
66+
newTerminal: data.newTerminal || undefined,
6567
shortcut: data.shortcut || undefined,
6668
terminalName: data.terminalName || undefined,
6769
};
@@ -320,16 +322,33 @@ export const CommandForm = ({
320322
</DropdownMenuContent>
321323
</DropdownMenu>
322324
</div>
323-
<div className="space-y-2">
324-
<FormLabel htmlFor="terminalName">{t("commandForm.terminalName")}</FormLabel>
325-
<Input
326-
error={!!errors.terminalName}
327-
errorMessage={errors.terminalName?.message}
328-
id="terminalName"
329-
placeholder={t("commandForm.terminalNamePlaceholder")}
330-
{...register("terminalName")}
331-
/>
332-
</div>
325+
{!useVsCodeApi && !insertOnly && (
326+
<>
327+
<div className="space-y-2">
328+
<FormLabel htmlFor="terminalName">{t("commandForm.terminalName")}</FormLabel>
329+
<Input
330+
error={!!errors.terminalName}
331+
errorMessage={errors.terminalName?.message}
332+
id="terminalName"
333+
placeholder={t("commandForm.terminalNamePlaceholder")}
334+
{...register("terminalName")}
335+
/>
336+
</div>
337+
<Controller
338+
control={control}
339+
name="newTerminal"
340+
render={({ field }) => (
341+
<Checkbox
342+
checked={field.value}
343+
description={t("commandForm.newTerminalDescription")}
344+
id="newTerminal"
345+
label={t("commandForm.newTerminal")}
346+
onCheckedChange={field.onChange}
347+
/>
348+
)}
349+
/>
350+
</>
351+
)}
333352
</>
334353
)}
335354

src/view/src/components/group-command-item.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useTranslation } from "react-i18next";
1212

1313
import {
1414
Button,
15+
Checkbox,
1516
Input,
1617
DropdownMenu,
1718
DropdownMenuTrigger,
@@ -174,6 +175,14 @@ export const GroupCommandItem = ({ command, id, index, onEditGroup }: GroupComma
174175
value={command.shortcut || ""}
175176
/>
176177
</div>
178+
{!command.useVsCodeApi && !command.insertOnly && (
179+
<Checkbox
180+
checked={command.newTerminal || false}
181+
id={`newTerminal-${id}`}
182+
label={t("commandForm.newTerminal")}
183+
onCheckedChange={(checked) => updateCommand(index, { newTerminal: !!checked })}
184+
/>
185+
)}
177186
</>
178187
)}
179188

src/view/src/i18n/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"insertOnlyDesc": "Insert Only (don't execute)",
4747
"terminalName": "Terminal Name (optional)",
4848
"terminalNamePlaceholder": "e.g., Build Terminal",
49+
"newTerminal": "Always create new terminal",
50+
"newTerminalDescription": "Create a fresh terminal each time instead of reusing existing one",
4951
"executeAll": "Execute all commands simultaneously",
5052
"groupCommandsLabel": "Group Commands",
5153
"color": "Color (optional)",

src/view/src/i18n/locales/ko.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"insertOnlyDesc": "입력만 (실행하지 않음)",
4747
"terminalName": "터미널 이름 (optional)",
4848
"terminalNamePlaceholder": "예: 빌드 터미널",
49+
"newTerminal": "항상 새 터미널 생성",
50+
"newTerminalDescription": "기존 터미널을 재사용하지 않고 매번 새 터미널 생성",
4951
"executeAll": "모든 명령 동시 실행",
5052
"groupCommandsLabel": "그룹 명령",
5153
"color": "색상 (optional)",

src/view/src/schemas/command-form-schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const buttonConfigSchema = z.lazy(() =>
3232
id: z.string(),
3333
insertOnly: z.boolean().optional(),
3434
name: z.string().min(1, "Command name is required"),
35+
newTerminal: z.boolean().optional(),
3536
shortcut: z.string().optional(),
3637
terminalName: z.string().optional(),
3738
useVsCodeApi: z.boolean().optional(),
@@ -48,6 +49,7 @@ export const createCommandFormSchema = (): z.ZodType<ButtonConfig> => {
4849
id: z.string(),
4950
insertOnly: z.boolean().optional(),
5051
name: z.string().min(1, "Command name is required"),
52+
newTerminal: z.boolean().optional(),
5153
shortcut: z.string().optional(),
5254
terminalName: z.string().optional(),
5355
useVsCodeApi: z.boolean().optional(),

src/view/src/types.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type ButtonConfigDraft = {
1818
index?: number;
1919
insertOnly?: boolean;
2020
name: string;
21+
newTerminal?: boolean;
2122
shortcut?: string;
2223
terminalName?: string;
2324
useVsCodeApi?: boolean;
@@ -30,6 +31,7 @@ export const toCommandButton = (draft: ButtonConfigDraft): CommandButton => ({
3031
index: draft.index,
3132
insertOnly: draft.insertOnly,
3233
name: draft.name,
34+
newTerminal: draft.newTerminal,
3335
shortcut: draft.shortcut,
3436
terminalName: draft.terminalName,
3537
useVsCodeApi: draft.useVsCodeApi,
@@ -54,6 +56,7 @@ export const toDraft = (config: ButtonConfig): ButtonConfigDraft => ({
5456
index: config.index,
5557
insertOnly: "insertOnly" in config ? config.insertOnly : undefined,
5658
name: config.name,
59+
newTerminal: "newTerminal" in config ? config.newTerminal : undefined,
5760
shortcut: config.shortcut,
5861
terminalName: "terminalName" in config ? config.terminalName : undefined,
5962
useVsCodeApi: "useVsCodeApi" in config ? config.useVsCodeApi : undefined,

0 commit comments

Comments
 (0)