Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/app/src/pages/session/session-side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,26 @@ export function SessionSidePanel(props: {
<Tabs.List
ref={(el: HTMLDivElement) => {
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)
}}
>
Expand Down
11 changes: 10 additions & 1 deletion packages/opencode/src/tool/apply_patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
Loading