-
Notifications
You must be signed in to change notification settings - Fork 3
feat: resizable sessions panel + full-width session titles #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
45accd1
8c1fd12
ceef527
53c58ea
104057e
8afe690
7b96127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,9 @@ const LAYOUT_STORAGE_KEY = "opencode.layout"; | |||||||
| // Default values | ||||||||
| const DEFAULT_REVIEW_WIDTH = 320; | ||||||||
| const DEFAULT_INFO_WIDTH = 256; | ||||||||
| const DEFAULT_SIDEBAR_WIDTH = 256; | ||||||||
| export const SIDEBAR_MIN_WIDTH = 180; | ||||||||
| export const SIDEBAR_MAX_WIDTH = 480; | ||||||||
|
|
||||||||
| interface PanelState { | ||||||||
| opened: boolean; | ||||||||
|
|
@@ -25,6 +28,7 @@ export type FileTab = { | |||||||
| interface LayoutState { | ||||||||
| review: PanelState; | ||||||||
| info: PanelState; | ||||||||
| sidebar: { width?: number }; | ||||||||
| tabs?: FileTab[]; | ||||||||
| activeTab?: string | null; // null = Review tab, string = file path | ||||||||
| } | ||||||||
|
|
@@ -48,6 +52,11 @@ interface LayoutContextValue { | |||||||
| close: () => void; | ||||||||
| resize: (width: number) => void; | ||||||||
| }; | ||||||||
| // Sidebar panel (sessions list) | ||||||||
| sidebar: { | ||||||||
| width: () => number; | ||||||||
| resize: (width: number) => void; | ||||||||
| }; | ||||||||
| // File tabs | ||||||||
| tabs: { | ||||||||
| all: () => FileTab[]; | ||||||||
|
|
@@ -86,6 +95,9 @@ function loadState(): LayoutState { | |||||||
| opened: parsed.info?.opened ?? false, | ||||||||
| width: parsed.info?.width ?? DEFAULT_INFO_WIDTH, | ||||||||
| }, | ||||||||
| sidebar: { | ||||||||
| width: parsed.sidebar?.width ?? DEFAULT_SIDEBAR_WIDTH, | ||||||||
| }, | ||||||||
| tabs, | ||||||||
| activeTab, | ||||||||
| }; | ||||||||
|
|
@@ -96,6 +108,7 @@ function loadState(): LayoutState { | |||||||
| return { | ||||||||
| review: { opened: false, width: DEFAULT_REVIEW_WIDTH }, | ||||||||
| info: { opened: false, width: DEFAULT_INFO_WIDTH }, | ||||||||
| sidebar: { width: DEFAULT_SIDEBAR_WIDTH }, | ||||||||
| tabs: [], | ||||||||
| activeTab: null, | ||||||||
| }; | ||||||||
|
|
@@ -124,6 +137,13 @@ export function LayoutProvider(props: ParentProps) { | |||||||
| initial.info.width ?? DEFAULT_INFO_WIDTH, | ||||||||
| ); | ||||||||
|
|
||||||||
| // Sidebar state (clamp loaded value to valid range) | ||||||||
| const [sidebarWidth, setSidebarWidth] = createSignal( | ||||||||
| Math.max(SIDEBAR_MIN_WIDTH, Math.min(SIDEBAR_MAX_WIDTH, | ||||||||
| initial.sidebar.width ?? DEFAULT_SIDEBAR_WIDTH, | ||||||||
| )), | ||||||||
| ); | ||||||||
|
|
||||||||
| // File tabs state | ||||||||
| const [fileTabs, setFileTabs] = createSignal<FileTab[]>(initial.tabs ?? []); | ||||||||
| const [activeTab, setActiveTab] = createSignal<string | null>( | ||||||||
|
|
@@ -135,6 +155,7 @@ export function LayoutProvider(props: ParentProps) { | |||||||
| saveState({ | ||||||||
| review: { opened: reviewOpened(), width: reviewWidth() }, | ||||||||
| info: { opened: infoOpened(), width: infoWidth() }, | ||||||||
| sidebar: { width: sidebarWidth() }, | ||||||||
| tabs: fileTabs(), | ||||||||
| activeTab: activeTab(), | ||||||||
| }); | ||||||||
|
|
@@ -181,6 +202,13 @@ export function LayoutProvider(props: ParentProps) { | |||||||
| persist(); | ||||||||
| }, | ||||||||
| }, | ||||||||
| sidebar: { | ||||||||
| width: sidebarWidth, | ||||||||
| resize: (width: number) => { | ||||||||
| setSidebarWidth(Math.max(SIDEBAR_MIN_WIDTH, Math.min(SIDEBAR_MAX_WIDTH, width))); | ||||||||
|
||||||||
| setSidebarWidth(Math.max(SIDEBAR_MIN_WIDTH, Math.min(SIDEBAR_MAX_WIDTH, width))); | |
| setSidebarWidth(Math.max(SIDEBAR_MIN_WIDTH, Math.min(SIDEBAR_MAX_WIDTH, width))); | |
| persist(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sidebar width clamping here can still produce
NaNifinitial.sidebar.widthis non-numeric (e.g., corrupted localStorage).Math.min/maxwithNaNreturnsNaN, which later becomes an invalid CSS width. Consider validating withNumber.isFinite(...)and falling back toDEFAULT_SIDEBAR_WIDTHbefore clamping.