Skip to content

Commit bda8421

Browse files
mswiszczclaudesawka
authored
feat: add widgets sidebar toggle button to view menu (#3140)
Add ability to toggle the Widgets sidebar visibility via a button in the tabbar. State persists across sessions and workspaces through workspace metadata (layout:widgetsvisible). --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: sawka <mike@commandline.dev>
1 parent 984b4e5 commit bda8421

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

emain/emain-menu.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,20 @@ function makeViewMenu(
311311
{
312312
role: "togglefullscreen",
313313
},
314+
{ type: "separator" },
315+
{
316+
label: "Toggle Widgets Bar",
317+
click: () => {
318+
fireAndForget(async () => {
319+
const workspaceId = focusedWaveWindow?.workspaceId;
320+
if (!workspaceId) return;
321+
const oref = `workspace:${workspaceId}`;
322+
const meta = await RpcApi.GetMetaCommand(ElectronWshClient, { oref });
323+
const current = meta?.["layout:widgetsvisible"] ?? true;
324+
await RpcApi.SetMetaCommand(ElectronWshClient, { oref, meta: { "layout:widgetsvisible": !current } });
325+
});
326+
},
327+
},
314328
];
315329
}
316330

frontend/app/workspace/workspace-layout-model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class WorkspaceLayoutModel {
5656
private focusTimeoutRef: NodeJS.Timeout | null = null;
5757
private debouncedPersistAIWidth: () => void;
5858
private debouncedPersistVTabWidth: () => void;
59+
widgetsSidebarVisibleAtom: jotai.Atom<boolean>;
5960

6061
private constructor() {
6162
this.aiPanelRef = null;
@@ -71,6 +72,11 @@ class WorkspaceLayoutModel {
7172
this.vtabWidth = VTabBar_DefaultWidth;
7273
this.vtabVisible = false;
7374
this.panelVisibleAtom = jotai.atom(false);
75+
this.widgetsSidebarVisibleAtom = jotai.atom(
76+
(get) =>
77+
get(getOrefMetaKeyAtom(WOS.makeORef("workspace", this.getWorkspaceId()), "layout:widgetsvisible")) ??
78+
true
79+
);
7480
this.initializeFromMeta();
7581

7682
this.handleWindowResize = this.handleWindowResize.bind(this);

frontend/app/workspace/workspace.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const WorkspaceElem = memo(() => {
4646
const tabBarPosition = useAtomValue(getSettingsKeyAtom("app:tabbar")) ?? "top";
4747
const showLeftTabBar = tabBarPosition === "left";
4848
const aiPanelVisible = useAtomValue(workspaceLayoutModel.panelVisibleAtom);
49+
const widgetsSidebarVisible = useAtomValue(workspaceLayoutModel.widgetsSidebarVisibleAtom);
4950
const windowWidth = window.innerWidth;
5051
const leftGroupInitialPct = workspaceLayoutModel.getLeftGroupInitialPercentage(windowWidth, showLeftTabBar);
5152
const innerVTabInitialPct = workspaceLayoutModel.getInnerVTabInitialPercentage(windowWidth, showLeftTabBar);
@@ -158,7 +159,7 @@ const WorkspaceElem = memo(() => {
158159
) : (
159160
<div className="flex flex-row h-full">
160161
<TabContent key={tabId} tabId={tabId} noTopPadding={showLeftTabBar && isMacOS()} />
161-
<Widgets />
162+
{widgetsSidebarVisible && <Widgets />}
162163
</div>
163164
)}
164165
</Panel>

frontend/types/gotypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ declare global {
11611161
"bg:bordercolor"?: string;
11621162
"bg:activebordercolor"?: string;
11631163
"layout:vtabbarwidth"?: number;
1164+
"layout:widgetsvisible"?: boolean;
11641165
"waveai:panelopen"?: boolean;
11651166
"waveai:panelwidth"?: number;
11661167
"waveai:model"?: string;

pkg/waveobj/metaconsts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const (
100100
MetaKey_BgActiveBorderColor = "bg:activebordercolor"
101101

102102
MetaKey_LayoutVTabBarWidth = "layout:vtabbarwidth"
103+
MetaKey_LayoutWidgetsVisible = "layout:widgetsvisible"
103104

104105
MetaKey_WaveAiPanelOpen = "waveai:panelopen"
105106
MetaKey_WaveAiPanelWidth = "waveai:panelwidth"

pkg/waveobj/wtypemeta.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ type MetaTSType struct {
102102
BgActiveBorderColor string `json:"bg:activebordercolor,omitempty"` // frame:activebordercolor
103103

104104
// for workspace
105-
LayoutVTabBarWidth int `json:"layout:vtabbarwidth,omitempty"`
105+
LayoutVTabBarWidth int `json:"layout:vtabbarwidth,omitempty"`
106+
LayoutWidgetsVisible *bool `json:"layout:widgetsvisible,omitempty"`
106107

107108
// for tabs+waveai
108109
WaveAiPanelOpen bool `json:"waveai:panelopen,omitempty"`

0 commit comments

Comments
 (0)