diff --git a/.jules/bolt.md b/.jules/bolt.md index c728fea75665..65721015b9b5 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -1,3 +1,6 @@ +## YYYY-MM-DD - [Title] +**Learning:** [Insight] +**Action:** [How to apply next time]. You are "Bolt" ⚡ - a performance-obsessed agent who makes the opencode codebase faster, one optimization at a time. Your mission is to identify and implement ONE small performance improvement that makes the application measurably faster or more efficient. diff --git a/bun.lock b/bun.lock index d69988c76d97..bed217b2f031 100644 --- a/bun.lock +++ b/bun.lock @@ -1,6 +1,5 @@ { "lockfileVersion": 1, - "configVersion": 1, "workspaces": { "": { "name": "opencode", diff --git a/packages/app/src/context/global-sync.tsx b/packages/app/src/context/global-sync.tsx index 5749291157e5..93a27d535e50 100644 --- a/packages/app/src/context/global-sync.tsx +++ b/packages/app/src/context/global-sync.tsx @@ -10,6 +10,7 @@ import type { import { showToast } from "@opencode-ai/ui/toast" import { getFilename } from "@opencode-ai/util/path" import { + batch, createContext, getOwner, Match, @@ -275,41 +276,49 @@ function createGlobalSync() { } const unsub = globalSDK.event.listen((e) => { - const directory = e.name - const event = e.details - - if (directory === "global") { - applyGlobalEvent({ - event, - project: globalStore.project, - refresh: queue.refresh, - setGlobalProject: setProjects, - }) - if (event.type === "server.connected" || event.type === "global.disposed") { - for (const directory of Object.keys(children.children)) { - queue.push(directory) + batch(() => { + const directory = e.name + const event = e.details + + if (directory === "global") { + applyGlobalEvent({ + event, + project: globalStore.project, + refresh: queue.refresh, + setGlobalProject(next) { + if (typeof next === "function") { + setGlobalStore("project", produce(next)) + return + } + setGlobalStore("project", next) + }, + }) + if (event.type === "server.connected" || event.type === "global.disposed") { + for (const directory of Object.keys(children.children)) { + queue.push(directory) + } } + return } - return - } - const existing = children.children[directory] - if (!existing) return - children.mark(directory) - const [store, setStore] = existing - applyDirectoryEvent({ - event, - directory, - store, - setStore, - push: queue.push, - setSessionTodo, - vcsCache: children.vcsCache.get(directory), - loadLsp: () => { - sdkFor(directory) - .lsp.status() - .then((x) => setStore("lsp", x.data ?? [])) - }, + const existing = children.children[directory] + if (!existing) return + children.mark(directory) + const [store, setStore] = existing + applyDirectoryEvent({ + event, + directory, + store, + setStore, + push: queue.push, + setSessionTodo, + vcsCache: children.vcsCache.get(directory), + loadLsp: () => { + sdkFor(directory) + .lsp.status() + .then((x) => setStore("lsp", x.data ?? [])) + }, + }) }) }) diff --git a/packages/app/src/context/sync.tsx b/packages/app/src/context/sync.tsx index ed54751c3ca5..ee288e0b567d 100644 --- a/packages/app/src/context/sync.tsx +++ b/packages/app/src/context/sync.tsx @@ -62,30 +62,34 @@ export function applyOptimisticRemove(draft: OptimisticStore, input: OptimisticR } function setOptimisticAdd(setStore: (...args: unknown[]) => void, input: OptimisticAddInput) { - setStore("message", input.sessionID, (messages: Message[] | undefined) => { - if (!messages) return [input.message] - const result = Binary.search(messages, input.message.id, (m) => m.id) - const next = [...messages] - next.splice(result.index, 0, input.message) - return next + batch(() => { + setStore("message", input.sessionID, (messages: Message[] | undefined) => { + if (!messages) return [input.message] + const result = Binary.search(messages, input.message.id, (m) => m.id) + const next = [...messages] + next.splice(result.index, 0, input.message) + return next + }) + setStore("part", input.message.id, sortParts(input.parts)) }) - setStore("part", input.message.id, sortParts(input.parts)) } function setOptimisticRemove(setStore: (...args: unknown[]) => void, input: OptimisticRemoveInput) { - setStore("message", input.sessionID, (messages: Message[] | undefined) => { - if (!messages) return messages - const result = Binary.search(messages, input.messageID, (m) => m.id) - if (!result.found) return messages - const next = [...messages] - next.splice(result.index, 1) - return next - }) - setStore("part", (part: Record) => { - if (!(input.messageID in part)) return part - const next = { ...part } - delete next[input.messageID] - return next + batch(() => { + setStore("message", input.sessionID, (messages: Message[] | undefined) => { + if (!messages) return messages + const result = Binary.search(messages, input.messageID, (m) => m.id) + if (!result.found) return messages + const next = [...messages] + next.splice(result.index, 1) + return next + }) + setStore("part", (part: Record) => { + if (!(input.messageID in part)) return part + const next = { ...part } + delete next[input.messageID] + return next + }) }) } diff --git a/references/OpenGUI b/references/OpenGUI index ee08ae46d48d..c4ad71997319 160000 --- a/references/OpenGUI +++ b/references/OpenGUI @@ -1 +1 @@ -Subproject commit ee08ae46d48dd86a1bfcb43d4e9949b8de5c3a17 +Subproject commit c4ad71997319cae49e7543dbc0fe78424c9be32a