Skip to content

Commit 4a73d51

Browse files
committed
fix(app): workspace reset issues
1 parent 63cd763 commit 4a73d51

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

packages/opencode/src/worktree/index.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,44 @@ export namespace Worktree {
219219
return [outputText(result.stderr), outputText(result.stdout)].filter(Boolean).join("\n")
220220
}
221221

222+
function failed(result: { stdout?: Uint8Array; stderr?: Uint8Array }) {
223+
return [outputText(result.stderr), outputText(result.stdout)].filter(Boolean).flatMap((chunk) =>
224+
chunk
225+
.split("\n")
226+
.map((line) => line.trim())
227+
.flatMap((line) => {
228+
const match = line.match(/^warning:\s+failed to remove\s+(.+):\s+/i)
229+
if (!match) return []
230+
const value = match[1]?.trim().replace(/^['"]|['"]$/g, "")
231+
if (!value) return []
232+
return [value]
233+
}),
234+
)
235+
}
236+
237+
async function prune(root: string, entries: string[]) {
238+
const base = await canonical(root)
239+
await Promise.all(
240+
entries.map(async (entry) => {
241+
const target = await canonical(path.resolve(root, entry))
242+
if (target === base) return
243+
if (!target.startsWith(`${base}${path.sep}`)) return
244+
await fs.rm(target, { recursive: true, force: true }).catch(() => undefined)
245+
}),
246+
)
247+
}
248+
249+
async function sweep(root: string) {
250+
const first = await $`git clean -ffdx`.quiet().nothrow().cwd(root)
251+
if (first.exitCode === 0) return first
252+
253+
const entries = failed(first)
254+
if (!entries.length) return first
255+
256+
await prune(root, entries)
257+
return $`git clean -ffdx`.quiet().nothrow().cwd(root)
258+
}
259+
222260
async function canonical(input: string) {
223261
const abs = path.resolve(input)
224262
const real = await fs.realpath(abs).catch(() => abs)
@@ -536,7 +574,7 @@ export namespace Worktree {
536574
throw new ResetFailedError({ message: errorText(resetToTarget) || "Failed to reset worktree to target" })
537575
}
538576

539-
const clean = await $`git clean -fdx`.quiet().nothrow().cwd(worktreePath)
577+
const clean = await sweep(worktreePath)
540578
if (clean.exitCode !== 0) {
541579
throw new ResetFailedError({ message: errorText(clean) || "Failed to clean worktree" })
542580
}

packages/ui/src/components/toast.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
flex-direction: column;
88
gap: 8px;
99
max-width: min(400px, calc(100vw - 64px));
10+
max-height: calc(100dvh - 96px);
1011
width: 100%;
12+
overflow: hidden;
1113
pointer-events: none;
1214

1315
[data-slot="toast-list"] {
@@ -17,6 +19,8 @@
1719
list-style: none;
1820
margin: 0;
1921
padding: 0;
22+
max-height: 100%;
23+
overflow-y: auto;
2024
}
2125
}
2226

@@ -26,6 +30,8 @@
2630
align-items: flex-start;
2731
gap: 20px;
2832
padding: 16px 20px;
33+
max-height: min(420px, calc(100dvh - 96px));
34+
overflow: hidden;
2935
pointer-events: auto;
3036
transition: all 150ms ease-out;
3137

@@ -91,8 +97,10 @@
9197
display: flex;
9298
flex-direction: column;
9399
gap: 2px;
100+
min-height: 0;
94101
min-width: 0;
95-
overflow: hidden;
102+
overflow-x: hidden;
103+
overflow-y: auto;
96104
}
97105

98106
[data-slot="toast-title"] {

0 commit comments

Comments
 (0)