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
22 changes: 21 additions & 1 deletion src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function App({
const [showLineNumbers, setShowLineNumbers] = useState(bootstrap.initialShowLineNumbers ?? true);
const [wrapLines, setWrapLines] = useState(bootstrap.initialWrapLines ?? false);
const [showHunkHeaders, setShowHunkHeaders] = useState(bootstrap.initialShowHunkHeaders ?? true);
const [sidebarVisible, setSidebarVisible] = useState(true);
const [showHelp, setShowHelp] = useState(false);
const [focusArea, setFocusArea] = useState<FocusArea>("files");
const [activeMenuId, setActiveMenuId] = useState<MenuId | null>(null);
Expand Down Expand Up @@ -83,7 +84,7 @@ export function App({
const bodyPadding = pagerMode ? 0 : BODY_PADDING;
const bodyWidth = Math.max(0, terminal.width - bodyPadding);
const responsiveLayout = resolveResponsiveLayout(layoutMode, terminal.width);
const showFilesPane = pagerMode ? false : responsiveLayout.showFilesPane;
const showFilesPane = pagerMode ? false : responsiveLayout.showFilesPane && sidebarVisible;
const centerWidth = bodyWidth;
const resolvedLayout = responsiveLayout.layout;
const currentHunk = selectedFile?.metadata.hunks[selectedHunkIndex];
Expand Down Expand Up @@ -247,6 +248,11 @@ export function App({
setWrapLines((current) => !current);
};

/** Toggle sidebar visibility independently of layout mode. */
const toggleSidebar = () => {
setSidebarVisible((current) => !current);
};

/** Toggle visibility of hunk metadata rows without changing the actual diff lines. */
const toggleHunkHeaders = () => {
setShowHunkHeaders((current) => !current);
Expand Down Expand Up @@ -354,6 +360,14 @@ export function App({
action: () => setLayoutMode("auto"),
},
{ kind: "separator" },
{
kind: "item",
label: "Sidebar",
hint: "s",
checked: sidebarVisible,
action: toggleSidebar,
},
{ kind: "separator" },
{
kind: "item",
label: "Agent notes",
Expand Down Expand Up @@ -678,6 +692,12 @@ export function App({
return;
}

if (key.name === "s") {
toggleSidebar();
closeMenu();
return;
}

if (key.name === "t") {
const currentIndex = THEMES.findIndex((theme) => theme.id === activeTheme.id);
const nextIndex = (currentIndex + 1) % THEMES.length;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/chrome/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function StatusBar({
if (canResizeDivider) {
hintParts.push("drag divider resize");
}
hintParts.push("space/b page", "/ filter", "[ ] hunk nav", "1 2 0 layout", "t theme", "a notes", "l lines", "w wrap", "m meta", "q quit");
hintParts.push("space/b page", "/ filter", "[ ] hunk nav", "1 2 0 layout", "s sidebar", "t theme", "a notes", "l lines", "w wrap", "m meta", "q quit");

return (
<box
Expand Down
4 changes: 2 additions & 2 deletions src/ui/lib/responsive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export function resolveResponsiveLayout(requestedLayout: LayoutMode, viewportWid
return {
viewport,
layout: "split",
showFilesPane: false,
showFilesPane: viewport === "full",
};
}

if (requestedLayout === "stack") {
return {
viewport,
layout: "stack",
showFilesPane: false,
showFilesPane: viewport === "full",
};
}

Expand Down
1 change: 0 additions & 1 deletion test/app-interactions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ describe("App interactions", () => {

frame = setup.captureCharFrame();
expect(frame).not.toContain("Split view");
expect(frame).not.toContain("│");
expect(frame).toContain("1 - export const alpha = 1;");
} finally {
await act(async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/app-responsive.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ describe("responsive shell", () => {
expect(forcedSplit).toMatch(/▌.*▌/);
expect(forcedSplit).not.toContain("drag divider resize");

expect(forcedStack).not.toContain("Files");
expect(forcedStack).toContain("M alpha.ts");
expect(forcedStack).not.toContain("Changeset summary");
expect(forcedStack).not.toMatch(/▌.*▌/);
expect(forcedStack).not.toContain("drag divider resize");
expect(forcedStack).toContain("drag divider resize");
});

test("pager mode stays responsive while hiding app chrome", async () => {
Expand Down
Loading