Skip to content

Commit e9671a0

Browse files
author
chenbo
committed
Harden desktop task argument handling
1 parent fb25a08 commit e9671a0

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

apps/desktop/src/main/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function registerIpc(): void {
7272
if (!existsSync(repo)) return { error: `Repository does not exist: ${repo}` };
7373

7474
const command = commandName();
75-
const args = ["oc", "run", task, "--repo", repo, "--max-loops", "2"];
75+
const args = ["oc", "run", "--repo", repo, "--max-loops", "2", "--", task];
7676
currentRepo = repo;
7777
currentTask = spawn(command, args, {
7878
cwd: repo,
@@ -158,7 +158,7 @@ function formatCommand(command: string, args: string[]): string {
158158
}
159159

160160
function normalizeTaskForCli(task: string): string {
161-
return task.trim().replace(/\s+/gu, " ");
161+
return task.trim().replace(/\s+/gu, " ").replaceAll('"', "'");
162162
}
163163

164164
function quoteArg(value: string): string {

apps/desktop/src/renderer/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function App() {
4949

5050
const commandPreview = useMemo(() => {
5151
const normalizedTask = normalizeTaskForCli(task);
52-
if (!repo || !normalizedTask) return 'opencode-plusplus.cmd oc run "<task>" --repo "<repo>" --max-loops 2';
53-
return `opencode-plusplus.cmd oc run "${normalizedTask}" --repo "${repo}" --max-loops 2`;
52+
if (!repo || !normalizedTask) return 'opencode-plusplus.cmd oc run --repo "<repo>" --max-loops 2 -- "<task>"';
53+
return `opencode-plusplus.cmd oc run --repo "${repo}" --max-loops 2 -- "${normalizedTask}"`;
5454
}, [repo, task]);
5555

5656
if (!bridge) {
@@ -207,7 +207,7 @@ function quoteArg(value: string): string {
207207
}
208208

209209
function normalizeTaskForCli(task: string): string {
210-
return task.trim().replace(/\s+/gu, " ");
210+
return task.trim().replace(/\s+/gu, " ").replaceAll('"', "'");
211211
}
212212

213213
createRoot(document.getElementById("root") as HTMLElement).render(<App />);

0 commit comments

Comments
 (0)