[PR #5218] Document keybind implementation architecture #11297

Closed
opened 2026-02-16 18:16:06 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5218

State: closed
Merged: No


The codebase lacked documentation on keybind implementation locations and architecture. This adds comprehensive technical documentation.

Changes

  • KEYBINDS.md: Documents the three-layer keybind architecture

    • Utility layer (src/util/keybind.ts): Parsing/matching logic for keybind strings
    • Context layer (src/cli/cmd/tui/context/keybind.tsx): Solid.js provider with leader key state management
    • Configuration layer (src/config/config.ts): Zod schema defining 40+ configurable keybinds
  • Includes architecture diagram, usage patterns, all available keybinds with defaults, and guide for adding new keybinds

  • README.md: Added reference link to documentation

Example usage pattern documented:

import { useKeybind } from "@tui/context/keybind"

const keybind = useKeybind()

// Match keyboard events
if (keybind.match("app_exit", event)) {
  // handle exit
}

// Display to user
const exitKey = keybind.print("app_exit") // "ctrl+c"
Original prompt

where are keybinds implemented?


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5218 **State:** closed **Merged:** No --- The codebase lacked documentation on keybind implementation locations and architecture. This adds comprehensive technical documentation. ## Changes - **KEYBINDS.md**: Documents the three-layer keybind architecture - Utility layer (`src/util/keybind.ts`): Parsing/matching logic for keybind strings - Context layer (`src/cli/cmd/tui/context/keybind.tsx`): Solid.js provider with leader key state management - Configuration layer (`src/config/config.ts`): Zod schema defining 40+ configurable keybinds - Includes architecture diagram, usage patterns, all available keybinds with defaults, and guide for adding new keybinds - **README.md**: Added reference link to documentation Example usage pattern documented: ```typescript import { useKeybind } from "@tui/context/keybind" const keybind = useKeybind() // Match keyboard events if (keybind.match("app_exit", event)) { // handle exit } // Display to user const exitKey = keybind.print("app_exit") // "ctrl+c" ``` <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > where are keybinds implemented? </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
yindo added the pull-request label 2026-02-16 18:16:06 -05:00
yindo closed this issue 2026-02-16 18:16:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11297