Skip to content
Merged
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
6 changes: 4 additions & 2 deletions packages/app/src/components/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ export const Terminal = (props: TerminalProps) => {
if (local.autoFocus !== false) focusTerminal()

if (typeof document !== "undefined" && document.fonts) {
document.fonts.ready.then(scheduleFit)
document.fonts.ready.then(scheduleFit).catch(() => {
// Ignore font loading errors — scheduleFit is best-effort
})
}

const onResize = t.onResize((size) => {
Expand All @@ -435,7 +437,7 @@ export const Terminal = (props: TerminalProps) => {
})
cleanups.push(() => disposeIfDisposable(onData))
const onKey = t.onKey((key) => {
if (key.key == "Enter") {
if (key.key === "Enter") {
props.onSubmit?.()
}
})
Expand Down
19 changes: 12 additions & 7 deletions packages/app/src/context/global-sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ function createGlobalSync() {
}) as typeof setGlobalStore

if (projectInit instanceof Promise) {
void projectInit.then(() => {
if (!active) return
if (projectWritten) return
const cached = projectCache.value
if (cached.length === 0) return
setGlobalStore("project", cached)
})
void projectInit
.then(() => {
if (!active) return
if (projectWritten) return
const cached = projectCache.value
if (cached.length === 0) return
setGlobalStore("project", cached)
})
.catch(() => {
// Project init failed — ignore; the sync loop will retry
})
}

const setSessionTodo = (
Expand Down Expand Up @@ -441,6 +445,7 @@ function createGlobalSync() {
if (typeof requestAnimationFrame === "function") {
eventFrame = requestAnimationFrame(() => {
eventFrame = undefined
if (!active) return
eventTimer = setTimeout(() => {
eventTimer = undefined
void globalSDK.event.start()
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
clearSessionPrefetch(directory, sessionIDs)
for (const sessionID of sessionIDs) {
globalSync.todo.set(sessionID, undefined)
clearOptimistic(directory, sessionID)
}
setStore(
produce((draft) => {
Expand Down
43 changes: 28 additions & 15 deletions packages/app/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1546,18 +1546,26 @@ export default function Layout(props: ParentProps) {

function connectProvider() {
const run = ++dialogRun
void import("@/components/dialog-select-provider").then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(() => <x.DialogSelectProvider />)
})
void import("@/components/dialog-select-provider")
.then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(() => <x.DialogSelectProvider />)
})
.catch(() => {
// Chunk failed to load — ignore; user can retry
})
}

function openServer() {
const run = ++dialogRun
void import("@/components/dialog-select-server").then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(() => <x.DialogSelectServer />)
})
void import("@/components/dialog-select-server")
.then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(() => <x.DialogSelectServer />)
})
.catch(() => {
// Chunk failed to load — ignore; user can retry
})
}

function openSettingsSurface() {
Expand Down Expand Up @@ -1774,13 +1782,18 @@ export default function Layout(props: ParentProps) {
resolve(result)
} else {
const run = ++dialogRun
void import("@/components/dialog-select-directory").then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(
() => <x.DialogSelectDirectory multiple={true} onSelect={resolve} />,
() => resolve(null),
)
})
void import("@/components/dialog-select-directory")
.then((x) => {
if (dialogDead || dialogRun !== run) return
dialog.show(
() => <x.DialogSelectDirectory multiple={true} onSelect={resolve} />,
() => resolve(null),
)
})
.catch(() => {
// Chunk failed to load — resolve gracefully
resolve(null)
})
}
}

Expand Down
31 changes: 19 additions & 12 deletions packages/opencode/src/control-plane/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,27 @@ export namespace Workspace {
continue
}
setStatus(space.id, "connected")
await parseSSE(res.body, signal, (evt) => {
const event = evt as SyncEvent.SerializedEvent
try {
await parseSSE(res.body, signal, (evt) => {
const event = evt as SyncEvent.SerializedEvent

try {
if (!event.type.startsWith("server.")) {
SyncEvent.replay(event)
try {
if (!event.type.startsWith("server.")) {
SyncEvent.replay(event)
}
} catch (err) {
log.warn("failed to replay sync event", {
workspaceID: space.id,
error: err,
})
}
} catch (err) {
log.warn("failed to replay sync event", {
workspaceID: space.id,
error: err,
})
}
})
})
} catch (err) {
log.warn("sync stream parse error", {
workspaceID: space.id,
error: err,
})
}
setStatus(space.id, "disconnected")
log.info("disconnected to sync: " + space.id)
await sleep(250)
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/tool/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ const synthesizeOutput = (
header = "status: running"
body = wrapper("")
break
default:
header = `status: ${(part as { status: string }).status}`
body = wrapper("")
break
}

return {
Expand Down
4 changes: 3 additions & 1 deletion packages/opencode/src/tool/apply_patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function isSensitiveFile(filePath: string) {
}

function notFound(error: unknown) {
return typeof error === "object" && error !== null && "reason" in error && (error as any).reason?._tag === "NotFound"
if (typeof error !== "object" || error === null || !("reason" in error)) return false
const reason = (error as Record<string, unknown>).reason
return typeof reason === "object" && reason !== null && "_tag" in reason && reason._tag === "NotFound"
}

function safeTotalDiff(changes: Array<{ diff: string; sensitive: boolean }>) {
Expand Down
Loading