This repository was archived by the owner on Jul 13, 2026. It is now read-only.
Repository navigation
Commit 89d948a
committed
fix(tui): use keymap.registerLayer with command.register fallback
OpenCode 1.14.42 (anomalyco/opencode#26053, "introduce opentui keymap as
sole key/cmd engine") removed api.command.register from the TUI plugin
API. The replacement is api.keymap.registerLayer({ commands, bindings }).
A later patch (1.14.44+) reinstated api.command.register as a deprecated
shim that translates internally to keymap.registerLayer, but versions
1.14.42–1.14.43 are still broken.
Magic Context's TUI was calling api.command.register unconditionally at
src/tui/index.tsx:468, throwing TypeError on init for any host >=1.14.42
where the shim hadn't landed yet. Because the call ran *before*
api.slots.register, the sidebar slot never registered either — so the
entire Magic Context TUI surface vanished, not just the command palette
entries.
Fix:
Extracted the single api.command.register call into a new helper
registerCommandPaletteEntries(api) that:
1. Prefers api.keymap.registerLayer when present (canonical 1.14.42+
API). Calling it directly skips the deprecation warning and works
without depending on the now-deprecated api.command namespace
existing at all. Translates each entry to the keymap shape:
namespace="palette" + name + title + category + run().
2. Falls back to api.command.register on hosts predating keymap
(1.14.0–1.14.41).
3. Logs no error if neither surface is present — the TUI host can still
load with the sidebar visible. /ctx-status and /ctx-recomp remain
reachable via server-side slash commands which bridge to the TUI
dialogs through RPC.
Reference: cortexkit#61, mirroring the same fix shipped to
cortexkit/aft#33 with the same pattern.
No rebuild needed: package.json exports point ./tui at the raw source
(./src/tui/index.tsx), so the fix is live as soon as the file is on
disk.1 parent a751d55 commit 89d948a
1 file changed
Lines changed: 97 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
456 | 544 | | |
457 | 545 | | |
458 | 546 | | |
| |||
465 | 553 | | |
466 | 554 | | |
467 | 555 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
486 | 565 | | |
487 | 566 | | |
488 | 567 | | |
| |||
0 commit comments