Skip to content

fix(llm): move default_bindings INSIDE configure() — Alt+* keys were dead#72

Merged
fentas merged 1 commit into
masterfrom
fix/llm-default-bindings
May 17, 2026
Merged

fix(llm): move default_bindings INSIDE configure() — Alt+* keys were dead#72
fentas merged 1 commit into
masterfrom
fix/llm-default-bindings

Conversation

@fentas
Copy link
Copy Markdown
Owner

@fentas fentas commented May 17, 2026

Bug

Regression from PR #70: every LLM Alt+letter binding silently missed. User report:

it seems that the alt shortcuts not working anymore

Cause

`default_bindings` was declared at the top level of `src/modules/llm.zig`, but `config.modules` actually stores the result of `llm.configure(.{...})` — i.e. the inner struct returned by the factory. The dispatcher walks that inner type with `@hasDecl(M, "default_bindings")`, so the top-level decl was invisible.

The pre-existing dispatch tests passed because the test fixtures (`ModuleWithBindings`) declared `default_bindings` directly on the struct — no `configure()` wrapper. They didn't exercise the real shape user configs use.

Fix

Move the slice INSIDE the `configure()` return type, alongside `name`, `config`, the action handlers, etc. — same scope `@hasDecl` walks for every other hook on the LLM module.

Regression test

New `FactoryModule(tag)` test fixture in `src/dispatch.zig` mirrors the real `pub fn configure(cfg) type` pattern and asserts the walker picks up both modules' `default_bindings`. Future module authors will trip the test if they put the decl at the wrong scope.

Test plan

  • `zig build test` — 484/484 pass (3 new dispatch tests; the new one is the regression guard)
  • `zig fmt --check` — clean
  • Manual: rebuild atty, press Alt+S / Alt+C / Alt+H — all fire correctly

🤖 Generated with Claude Code

…dead

Regression from #70: `default_bindings` sat at the top level of
`src/modules/llm.zig`, but `config.modules` actually stores the
RESULT of `llm.configure(.{...})` — i.e. the inner struct returned
by the factory. The dispatcher's `@hasDecl(M, "default_bindings")`
gate inspects the inner struct, so the top-level decl was invisible
and every Alt+letter LLM binding silently missed.

Fix: move the slice into the `configure()` return type alongside
`name`, `config`, the action handlers, etc. — same scope `@hasDecl`
walks for every other hook on the LLM module.

Regression test (`allDefaultBindings: picks up bindings from
configure()-style factory modules`) mirrors the real
`pub fn configure(cfg) type` pattern via a `FactoryModule(tag)`
fixture, so future module authors don't re-hit this trap.

`zig build test` (484 pass) + `zig fmt --check` clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fentas fentas merged commit c29077e into master May 17, 2026
3 checks passed
@fentas fentas deleted the fix/llm-default-bindings branch May 17, 2026 19:06
@github-actions github-actions Bot mentioned this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant