diff --git a/packages/app/src/pages/session/session-side-panel.tsx b/packages/app/src/pages/session/session-side-panel.tsx index 07b18f3146d..ea840886509 100644 --- a/packages/app/src/pages/session/session-side-panel.tsx +++ b/packages/app/src/pages/session/session-side-panel.tsx @@ -218,6 +218,26 @@ export function SessionSidePanel(props: { { const stop = createFileTabListSync({ el, contextOpen }) + let prevActiveTab = activeTab() + createEffect(() => { + const currentTab = activeTab() + if (currentTab && currentTab !== prevActiveTab) { + const trigger = el.querySelector(`[data-value="${currentTab}"]`) as HTMLElement + if (trigger) { + const containerRect = el.getBoundingClientRect() + const triggerRect = trigger.getBoundingClientRect() + const isOverflowed = triggerRect.right > containerRect.right || triggerRect.left < containerRect.left + if (isOverflowed) { + const scrollLeft = el.scrollLeft + (triggerRect.left - containerRect.left) + el.scrollTo({ + left: scrollLeft, + behavior: "smooth", + }) + } + } + } + prevActiveTab = currentTab + }) onCleanup(stop) }} > diff --git a/packages/opencode/src/tool/apply_patch.ts b/packages/opencode/src/tool/apply_patch.ts index 06293b6eba6..432a4eb5e2c 100644 --- a/packages/opencode/src/tool/apply_patch.ts +++ b/packages/opencode/src/tool/apply_patch.ts @@ -58,6 +58,12 @@ export const ApplyPatchTool = Tool.define("apply_patch", { let totalDiff = "" for (const hunk of hunks) { + if (process.platform === "win32" && hunk.path.includes("USERNAME")) { + throw new Error( + `apply_patch verification failed: Path contains "USERNAME" which may indicate an unexpanded ` + + `environment variable or corrupted patch: ${hunk.path}`, + ) + } const filePath = path.resolve(Instance.directory, hunk.path) await assertExternalDirectory(ctx, filePath) @@ -92,9 +98,12 @@ export const ApplyPatchTool = Tool.define("apply_patch", { case "update": { // Check if file exists for update const stats = await fs.stat(filePath).catch(() => null) - if (!stats || stats.isDirectory()) { + if (!stats) { throw new Error(`apply_patch verification failed: Failed to read file to update: ${filePath}`) } + if (stats.isDirectory()) { + throw new Error(`apply_patch verification failed: Path is a directory, not a file: ${filePath}`) + } const oldContent = await fs.readFile(filePath, "utf-8") let newContent = oldContent