diff options
| author | Adam <[email protected]> | 2026-01-01 05:23:00 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-01-01 05:23:07 -0600 |
| commit | 6e7fc30f9407f48074852415e2c35958b82b78ed (patch) | |
| tree | 9d2c0d8bddac44d80e4a6f51df4182e94e84c895 /packages/app/src/context | |
| parent | 03733b0505989cf23538cdbb4f1644fae109b4b7 (diff) | |
| download | opencode-6e7fc30f9407f48074852415e2c35958b82b78ed.tar.gz opencode-6e7fc30f9407f48074852415e2c35958b82b78ed.zip | |
feat(app): context window window
Diffstat (limited to 'packages/app/src/context')
| -rw-r--r-- | packages/app/src/context/layout.tsx | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/packages/app/src/context/layout.tsx b/packages/app/src/context/layout.tsx index 156adc4ff..613a0e0c1 100644 --- a/packages/app/src/context/layout.tsx +++ b/packages/app/src/context/layout.tsx @@ -209,38 +209,58 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( }, async open(tab: string) { const current = store.sessionTabs[sessionKey] ?? { all: [] } - if (tab !== "review") { - if (!current.all.includes(tab)) { - if (!store.sessionTabs[sessionKey]) { - setStore("sessionTabs", sessionKey, { all: [tab], active: tab }) - } else { - setStore("sessionTabs", sessionKey, "all", [...current.all, tab]) - setStore("sessionTabs", sessionKey, "active", tab) - } + + if (tab === "review") { + if (!store.sessionTabs[sessionKey]) { + setStore("sessionTabs", sessionKey, { all: [], active: tab }) return } + setStore("sessionTabs", sessionKey, "active", tab) + return } - if (!store.sessionTabs[sessionKey]) { - setStore("sessionTabs", sessionKey, { all: [], active: tab }) - } else { + + if (tab === "context") { + const all = [tab, ...current.all.filter((x) => x !== tab)] + if (!store.sessionTabs[sessionKey]) { + setStore("sessionTabs", sessionKey, { all, active: tab }) + return + } + setStore("sessionTabs", sessionKey, "all", all) setStore("sessionTabs", sessionKey, "active", tab) + return } + + if (!current.all.includes(tab)) { + if (!store.sessionTabs[sessionKey]) { + setStore("sessionTabs", sessionKey, { all: [tab], active: tab }) + return + } + setStore("sessionTabs", sessionKey, "all", [...current.all, tab]) + setStore("sessionTabs", sessionKey, "active", tab) + return + } + + if (!store.sessionTabs[sessionKey]) { + setStore("sessionTabs", sessionKey, { all: current.all, active: tab }) + return + } + setStore("sessionTabs", sessionKey, "active", tab) }, close(tab: string) { const current = store.sessionTabs[sessionKey] if (!current) return + + const all = current.all.filter((x) => x !== tab) batch(() => { - setStore( - "sessionTabs", - sessionKey, - "all", - current.all.filter((x) => x !== tab), - ) - if (current.active === tab) { - const index = current.all.findIndex((f) => f === tab) - const previous = current.all[Math.max(0, index - 1)] - setStore("sessionTabs", sessionKey, "active", previous) + setStore("sessionTabs", sessionKey, "all", all) + if (current.active !== tab) return + + const index = current.all.findIndex((f) => f === tab) + if (index <= 0) { + setStore("sessionTabs", sessionKey, "active", undefined) + return } + setStore("sessionTabs", sessionKey, "active", current.all[index - 1]) }) }, move(tab: string, to: number) { |
