8000 fix(browser): persist browser pane width across restarts by schroldgames · Pull Request #26 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .claude/settings.local.json

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ release/

# Local Netlify folder
.netlify

# Local Claude Code settings
.claude/settings.local.json
16 changes: 13 additions & 3 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ export default function App() {
shell: ws.shell,
cwd: ws.cwd, // issue #20 — restore so new terminals reopen in the workspace folder
splitTree: ws.splitTree,
browserUrl: ws.browserUrl,
browserWidth: ws.browserWidth,
})),
}],
};
Expand All @@ -461,6 +463,9 @@ export default function App() {

// Auto-focus first pane whenever the active workspace changes or gains its first pane
const activeWorkspace = workspaces.find((w) => w.id === activeWorkspaceId) ?? null;
// During drag use live browserWidth state; otherwise use the persisted value from the
// workspace (falls back to browserWidth for workspaces that have never been resized).
const displayBrowserWidth = isResizingBrowser ? browserWidth : (activeWorkspace?.browserWidth ?? browserWidth);

useEffect(() => {
if (!activeWorkspace) return;
Expand Down Expand Up @@ -508,6 +513,7 @@ export default function App() {
cwd: ws.cwd || '',
splitTree: ws.splitTree,
browserUrl: ws.browserUrl || '',
browserWidth: ws.browserWidth,
})),
sidebarWidth,
terminalPrefs: { ...state.terminalPrefs },
Expand Down Expand Up @@ -700,15 +706,19 @@ export default function App() {
e.preventDefault();
setIsResizingBrowser(true);
const startX = e.clientX;
const startWidth = browserWidth;
const startWidth = activeWorkspace?.browserWidth ?? browserWidth;
setBrowserWidth(startWidth);
let finalWidth = startWidth;
const MouseEvent) => {
const delta = startX - ev.clientX;
setBrowserWidth(Math.max(250, Math.min(800, startWidth + delta)));
finalWidth = Math.max(250, Math.min(window.innerWidth - 400, startWidth + delta));
setBrowserWidth(finalWidth);
};
const => {
setIsResizingBrowser(false);
document.removeEventListener('mousemove', onMove);
document.removeEventListener('mouseup', onUp);
if (activeWorkspaceId) updateWorkspaceMetadata(activeWorkspaceId as any, { browserWidth: finalWidth });
};
document.addEventListener('mousemove', onMove);
document.addEventListener('mouseup', onUp);
Expand All @@ -724,7 +734,7 @@ export default function App() {
transform: 'translateX(-50%)',
}} />
</div>
<div style={{ width: browserWidth, flexShrink: 0, overflow: 'hidden', position: 'relative' }}>
<div style={{ width: displayBrowserWidth, flexShrink: 0, overflow: 'hidden', position: 'relative' }}>
{isResizingBrowser && (
<div style={{
position: 'absolute', inset: 0, zIndex: 10,
Expand Down
8000
1 change: 1 addition & 0 deletions src/renderer/store/workspace-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const createWorkspaceSlice: StateCreator<WorkspaceSlice> = (set, get) =>
customColor: config.customColor,
cwd: config.cwd,
browserUrl: config.browserUrl,
browserWidth: config.browserWidth,
}));

// IDs are regenerated above, so a saved activeWorkspaceId is meaningless —
Expand Down
1 change: 1 addition & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface WorkspaceInfo {
notificationText?: string;
shellState?: 'idle' | 'running' | 'interrupted';
browserUrl?: string;
browserWidth?: number;
}

// Surface
Expand Down
0