Add a dedicated footer line pointing to `[tui.keymap]` in `~/.codex/config.toml` so users can find where to rebind shortcuts. Refresh tooltips and snapshots to mention the config entry and the keymap template URL.
8.1 KiB
Keymap Rewrite Handoff
Updated: February 19, 2026
Repo: codex-config-keybinds
Branch: joshka/keymap-rewrite-start
Purpose
This handoff is the authoritative context for finishing and shipping the keymap rewrite commit stack.
The original implementation existed as a single large commit (0f03e76c). The current stack
reorders that work into additive, review-friendly commits while preserving behavioral intent.
Key decisions that still apply:
- Preserve end-state behavior equivalent to
0f03e76c. - Keep
AGENTS.mdkeymap guidance in the stack. - Treat keybinding coverage as a keymap-focused gate (not whole-crate perfection).
Quick Orientation
Summary for incoming implementer:
- The keymap feature is mostly implemented and wired.
- The remaining technical gate is branch coverage closure on keybinding branches.
- Preserve behavior while tightening internals and documentation quality.
- Keep help affordances succinct and clearly visible.
Read these in order:
docs/keymap-rewrite-handoff.md- Overall constraints, current status, and concrete next steps.
docs/tui-keymap.md- Long-term architecture and behavior model for configurable keymaps.
docs/keymap-action-matrix.md- Action-by-action reference mapping and expected command behavior.
docs/config.md- User-facing config contract and migration notes for presets.
docs/default-keymap.toml- Canonical template that should match the actual runtime/default behavior.
codex-rs/tui/src/keymap.rs- Core resolver and matching logic.
codex-rs/tui/src/bottom_pane/footer.rs- Help/affordance rendering and keymap customization guidance text.
Keymap Implementation Constraints (Must Hold)
- Behavioral contract:
- Preserve existing runtime behavior first, then refactor.
- End-state behavior should remain equivalent to
0f03e76c.
- Keymap type organization:
- Keep
TuiKeymap,TuiKeymapPreset, and related keymap types out of oversized umbrella files (for exampletypes.rs) and in dedicated module files.
- Keep
- Preset/versioning policy:
- Do not mutate historical preset defaults.
- Add new preset versions for behavior changes and keep
latestas an explicit pointer. - Update both
docs/default-keymap.tomlanddocs/config.mdwith migration notes whenever preset behavior changes.
- Simplification policy:
- Prefer reducing keymap repetition with small declarative macros where readability improves.
- Centralize key-event matching logic on
KeyBinding/keybinding helpers rather than repeating ad-hoc comparisons across callsites. - Document new macros and helper abstractions with rustdoc/doc comments.
- If
key_hint::plain...helpers are macroized, document invocation patterns and generated behavior with rustdoc and examples.
- Help and affordance UX:
- Keep keymap customization affordances succinct.
- Show the keymap affordance on its own line; avoid wrapped wording that buries the action.
- Documentation expectations:
- Write long-term "how this works" documentation, not process diary notes.
- Keep details that affect behavior, contracts, or extension points.
- Keep docs self-contained for a new engineer without depending on external notes.
- Run a documentation pass mindset on changed modules: explain invariants and decision boundaries, not just mechanics.
- Template/docs link policy:
docs/default-keymap.tomlmust point to a public URL for canonical docs (GitHub for now; laterdevelopers.openai.com).
- Test and coverage gates:
- Add characterization tests for pre-existing event behavior before swapping bindings.
- Maintain compile correctness across all callsites when APIs change (for example, constructor arity updates).
- Use
cargo llvm-covbranch coverage and push toward 100% on keybinding-related branches.
Context And Rationale (Self-Contained)
This document is intentionally self-contained for implementation handoff.
Source of truth for intent and behavior:
- Existing long-term docs in this repo:
docs/tui-keymap.md,docs/keymap-action-matrix.md, anddocs/keymap-rollout-plan.md. - Commit stack and diffs listed below.
- Test and coverage commands listed in this document.
Current Additive Stack (Authoritative)
-
b455e26a4a3edocs(keymap): establish long-term keymap documentationScope: long-term docs/spec (
docs/tui-keymap.md, action matrix, template, config docs, rollout plan). -
1913b55afb75feat(core): add keymap config schema and typesScope: additive config surface only (
core/src/config/tui_keymap.rs, schema, config exports). -
187aa6969e03test(tui): add runtime keymap resolver characterization suiteScope:
tui/src/keymap.rsandkey_hinthelper expansion, with resolver tests and conflict guards, but no broad runtime wiring yet. -
aeb6caaecbbcfeat(tui): wire runtime keymap into event handlingScope: replace hardcoded key checks across app/composer/pager/approval/onboarding/list/textarea routing with runtime keymap usage.
-
HEADfeat(tui): surface keymap customization hintsScope: UX/help affordances (
footer.rs, tooltip text, snapshot updates) plus this handoff doc.
Validation Evidence (Current)
All commands below were run in this workspace.
-
Config commit (
1913b55afb75)cd codex-rs && just fmtcd codex-rs && cargo test -p codex-core --lib- Result: pass (
996 passed; 0 failed; 4 ignored).
-
Resolver/characterization commit (
187aa6969e03)cd codex-rs && just fmtcd codex-rs && cargo test -p codex-tui- Result: pass (
797 passed; 0 failed; 2 ignored+ integration/doctest pass).
-
Wiring commit (
aeb6caaecbbc)cd codex-rs && just fmtcd codex-rs && cargo test -p codex-tui- Result: pass (
806 passed; 0 failed; 2 ignored+ integration/doctest pass).
-
UX/hints commit (
HEAD)cd codex-rs && just fmtcd codex-rs && cargo test -p codex-tui- Result: pass (
806 passed; 0 failed; 2 ignored+ integration/doctest pass).
-
Post-rebase integration validation (current workspace)
cd codex-rs && just fmtcd codex-rs && cargo test -p codex-tui- Result: pass (
932 passed; 0 failed; 2 ignored+ integration/doctest pass).
Coverage Status (Important)
Branch-coverage closure is still pending and is the main remaining technical gate.
What happened:
cargo llvm-cov --branchon stable failed as expected (needs nightly-Zsupport).- Nightly toolchain exists locally, and
llvm-tools-previewis installed for nightly. - A nightly branch-coverage run was started but interrupted before artifact emission.
- No
/tmp/codex_tui_cov.jsonwas produced in the latest attempt.
Implication:
- Do not claim branch-coverage completion yet.
- Next dev should run and record a successful branch report before declaring done.
Remaining Work To Finish This Effort
- Complete keybinding branch coverage run and record results.
- Add missing tests if branch gaps remain in
tui/src/keymap.rsor key-routing branches. - Re-run
cargo test -p codex-tuiafter any coverage-driven test additions. - Decide whether
docs/keymap-rollout-plan.mdremains in the final PR scope or is dropped as implementation scaffolding. - Final review pass on commit descriptions and stack readability, then push/open PR.
Recommended Resume Commands
Run these first to rehydrate state:
git fetch origin
git status --short
git log --oneline --decorate --graph origin/main..HEAD
git diff --stat origin/main...HEAD
git diff origin/main...HEAD
Then run coverage work:
cd codex-rs
cargo +nightly llvm-cov -p codex-tui --tests --branch --json --output-path /tmp/codex_tui_cov.json
cargo +nightly llvm-cov report --summary-only
If needed, inspect key files directly in the coverage JSON and add tests before re-running.
Notes For Reviewer/Implementer Handoff
- The stack is intentionally additive and readable now; avoid collapsing commits unless explicitly requested.
- Commit 4 contains the behavioral swap; commit 5 should stay UX-only.
- Keep this file in-tree until PR merge so reviewers and follow-up implementers share one authoritative source of context.