diff options
| author | Kit Langton <[email protected]> | 2026-03-27 14:11:50 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-27 14:11:50 -0400 |
| commit | e973bbf54a519566bfdccce3474178b26b163a6d (patch) | |
| tree | ad0d0aaa8408b62c4a41a4dc005a08a50c8aa0ad /packages/app | |
| parent | d36b38e4a6f5b778644669ba281fb5a35cf2f028 (diff) | |
| download | opencode-e973bbf54a519566bfdccce3474178b26b163a6d.tar.gz opencode-e973bbf54a519566bfdccce3474178b26b163a6d.zip | |
fix(app): default file tree to closed with minimum width (#19426)
Diffstat (limited to 'packages/app')
| -rw-r--r-- | packages/app/src/context/layout.tsx | 23 | ||||
| -rw-r--r-- | packages/app/src/pages/session.tsx | 9 |
2 files changed, 21 insertions, 11 deletions
diff --git a/packages/app/src/context/layout.tsx b/packages/app/src/context/layout.tsx index 78928118d..640d5e02e 100644 --- a/packages/app/src/context/layout.tsx +++ b/packages/app/src/context/layout.tsx @@ -13,7 +13,8 @@ import { createScrollPersistence, type SessionScroll } from "./layout-scroll" import { createPathHelpers } from "./file/path" const AVATAR_COLOR_KEYS = ["pink", "mint", "orange", "purple", "cyan", "lime"] as const -const DEFAULT_PANEL_WIDTH = 344 +const DEFAULT_SIDEBAR_WIDTH = 344 +const DEFAULT_FILE_TREE_WIDTH = 200 const DEFAULT_SESSION_WIDTH = 600 const DEFAULT_TERMINAL_HEIGHT = 280 export type AvatarColorKey = (typeof AVATAR_COLOR_KEYS)[number] @@ -161,11 +162,11 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( if (!isRecord(fileTree)) return fileTree if (fileTree.tab === "changes" || fileTree.tab === "all") return fileTree - const width = typeof fileTree.width === "number" ? fileTree.width : DEFAULT_PANEL_WIDTH + const width = typeof fileTree.width === "number" ? fileTree.width : DEFAULT_FILE_TREE_WIDTH return { ...fileTree, opened: true, - width: width === 260 ? DEFAULT_PANEL_WIDTH : width, + width: width === 260 ? DEFAULT_FILE_TREE_WIDTH : width, tab: "changes", } })() @@ -230,7 +231,7 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( createStore({ sidebar: { opened: false, - width: DEFAULT_PANEL_WIDTH, + width: DEFAULT_SIDEBAR_WIDTH, workspaces: {} as Record<string, boolean>, workspacesDefault: false, }, @@ -243,8 +244,8 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( panelOpened: true, }, fileTree: { - opened: true, - width: DEFAULT_PANEL_WIDTH, + opened: false, + width: DEFAULT_FILE_TREE_WIDTH, tab: "changes" as "changes" | "all", }, session: { @@ -628,32 +629,32 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( }, fileTree: { opened: createMemo(() => store.fileTree?.opened ?? true), - width: createMemo(() => store.fileTree?.width ?? DEFAULT_PANEL_WIDTH), + width: createMemo(() => store.fileTree?.width ?? DEFAULT_FILE_TREE_WIDTH), tab: createMemo(() => store.fileTree?.tab ?? "changes"), setTab(tab: "changes" | "all") { if (!store.fileTree) { - setStore("fileTree", { opened: true, width: DEFAULT_PANEL_WIDTH, tab }) + setStore("fileTree", { opened: true, width: DEFAULT_FILE_TREE_WIDTH, tab }) return } setStore("fileTree", "tab", tab) }, open() { if (!store.fileTree) { - setStore("fileTree", { opened: true, width: DEFAULT_PANEL_WIDTH, tab: "changes" }) + setStore("fileTree", { opened: true, width: DEFAULT_FILE_TREE_WIDTH, tab: "changes" }) return } setStore("fileTree", "opened", true) }, close() { if (!store.fileTree) { - setStore("fileTree", { opened: false, width: DEFAULT_PANEL_WIDTH, tab: "changes" }) + setStore("fileTree", { opened: false, width: DEFAULT_FILE_TREE_WIDTH, tab: "changes" }) return } setStore("fileTree", "opened", false) }, toggle() { if (!store.fileTree) { - setStore("fileTree", { opened: true, width: DEFAULT_PANEL_WIDTH, tab: "changes" }) + setStore("fileTree", { opened: true, width: DEFAULT_FILE_TREE_WIDTH, tab: "changes" }) return } setStore("fileTree", "opened", (x) => !x) diff --git a/packages/app/src/pages/session.tsx b/packages/app/src/pages/session.tsx index 752b549b8..11e6375b3 100644 --- a/packages/app/src/pages/session.tsx +++ b/packages/app/src/pages/session.tsx @@ -1640,6 +1640,15 @@ export default function Page() { consumePendingMessage: layout.pendingMessage.consume, }) + createEffect( + on( + () => params.id, + (id) => { + if (!id) requestAnimationFrame(() => inputRef?.focus()) + }, + ), + ) + onMount(() => { document.addEventListener("keydown", handleKeyDown) }) |
