diff options
| author | Adam <[email protected]> | 2025-10-13 06:09:02 -0500 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-10-14 07:15:08 -0500 |
| commit | bb82d4309435f2052e98531e8d955198fb1c55ba (patch) | |
| tree | 9455ff36a5fec5d147425c2b2fae982a82b94fca /packages/desktop/src/context | |
| parent | 2893b6e3a58a25514bb8d75c68f893ea5f2b593a (diff) | |
| download | opencode-bb82d4309435f2052e98531e8d955198fb1c55ba.tar.gz opencode-bb82d4309435f2052e98531e8d955198fb1c55ba.zip | |
wip: desktop work
Diffstat (limited to 'packages/desktop/src/context')
| -rw-r--r-- | packages/desktop/src/context/local.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/desktop/src/context/local.tsx b/packages/desktop/src/context/local.tsx index 4c2a3d3be..b04c70f0f 100644 --- a/packages/desktop/src/context/local.tsx +++ b/packages/desktop/src/context/local.tsx @@ -202,6 +202,13 @@ function init() { } } + const init = async (path: string) => { + const relativePath = relative(path) + if (!store.node[relativePath]) await fetch(path) + if (store.node[relativePath].loaded) return + return load(relativePath) + } + const open = async (path: string, options?: { pinned?: boolean; view?: LocalFile["view"] }) => { const relativePath = relative(path) if (!store.node[relativePath]) await fetch(path) @@ -271,6 +278,7 @@ function init() { update: (path: string, node: LocalFile) => setStore("node", path, reconcile(node)), open, load, + init, close(path: string) { setStore("opened", (opened) => opened.filter((x) => x !== path)) if (store.active === path) { @@ -473,11 +481,16 @@ function init() { const context = (() => { const [store, setStore] = createStore<{ activeTab: boolean + files: string[] + activeFile?: string items: (ContextItem & { key: string })[] }>({ activeTab: true, + files: [], items: [], }) + const files = createMemo(() => store.files.map((x) => file.node(x))) + const activeFile = createMemo(() => (store.activeFile ? file.node(store.activeFile) : undefined)) return { all() { @@ -505,6 +518,17 @@ function init() { remove(key: string) { setStore("items", (x) => x.filter((x) => x.key !== key)) }, + files, + openFile(path: string) { + file.init(path).then(() => { + setStore("files", (x) => [...x, path]) + setStore("activeFile", path) + }) + }, + activeFile, + setActiveFile(path: string | undefined) { + setStore("activeFile", path) + }, } })() |
