Skip to content

Add keyboard shortcut for Git panel toggle (⌘6) #193

Description

@M-Igashi

Background

Inspired by the Zellij + Yazi + Helix + Lazygit one-key navigation pattern described in 脱IDE。AI時代の開発を支えるRust製ターミナル環境.

The article demonstrates seamless keyboard-driven transitions between file manager → editor → git client. MarkUpsideDown has the same three panels (Sidebar file tree, CodeMirror editor, Git panel) but the Git panel lacks a direct keyboard shortcut.

Current state

Shortcut Action
⌘1 Toggle Sidebar (file tree)
⌘2 Toggle Editor
⌘3 Toggle Preview
⌘4 Toggle Table of Contents
⌘5 Semantic Search
Git panel: no shortcut (click nav button only)

The sidebar has an internal panel system (SidebarPanel = "files" | "git" | "clone") with switchPanel() exported from sidebar.ts, but main.ts does not import or use it.

Proposal

⌘6 — Toggle Git Panel

Behavior:

  • If sidebar is collapsed → expand sidebar + switch to git panel
  • If sidebar is visible but on a different panel → switch to git panel
  • If sidebar is visible and already showing git panel → collapse sidebar

This follows the toggle pattern already used by ⌘1 (sidebar) and ⌘4 (TOC).

Implementation

  1. Import switchPanel from sidebar.ts in main.ts
  2. Add a toggleGitPanel() function:
    function toggleGitPanel() {
      const isCollapsed = sidebarEl.classList.contains("collapsed");
      const isGitActive = /* check current active panel */;
      if (!isCollapsed && isGitActive) {
        toggleSidebar(); // collapse
      } else {
        if (isCollapsed) toggleSidebar(); // expand
        switchPanel("git");
      }
    }
  3. Add ⌘6 handler in the keydown listener (between ⌘5 and the ⌘C handler)
  4. Register in command palette:
    { id: "view.gitPanel", label: "Toggle Git Panel", shortcut: "⌘6", category: "View", run: toggleGitPanel }

Files to modify

  • ui/src/main.ts — import switchPanel, add keydown handler + command registration
  • ui/src/sidebar.ts — may need to export activePanel getter (currently activePanel is a module-level let)

Scope

Small change — no new dependencies, no architectural changes. Keyboard-only workflow improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions