From 7b376faedefd5c250e51a8224eee871fceb787d1 Mon Sep 17 00:00:00 2001 From: IOANNIS MANOLOGLOU Date: Wed, 25 Feb 2026 17:25:12 +0200 Subject: [PATCH] Fixes for issues #11674 and #11687 - Scroll to active tab when clicked (fixes #11674) - Validate paths on Windows for unexpanded USERNAME environment variable (fixes #11687) --- .../src/pages/session/session-side-panel.tsx | 20 +++++++++++++++++++ packages/opencode/src/tool/apply_patch.ts | 11 +++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/app/src/pages/session/session-side-panel.tsx b/packages/app/src/pages/session/session-side-panel.tsx index 07b18f3146d5..ea8408865092 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 06293b6eba6e..432a4eb5e2c0 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