Commit 314e1df
authored
refactor: shell integration speaks v2 JSON-RPC on the direct socket path (#72)
* fix: mismatched brace/paren in _cmux_start_pr_poll_loop broke bash sourcing
_cmux_start_pr_poll_loop opened its backgrounded PR-poll loop with a bare
`{` but closed it with `)` (typo introduced in 88d6a2f, March 2026).
A `{ ... }` group must close with `}`; mixing it with `)` is a syntax
error, and bash apparently fails the syntax check for the entire file, not
just the malformed function — sourcing programa-bash-integration.bash in a
live shell (bash 3.2 and 5.3 both tested) aborts entirely with 'syntax
error near unexpected token )', so no shell-integration function gets
defined at all.
Found while running `bash -n` as part of verifying an unrelated change
(the v1->v2 JSON-RPC migration in the following commits); confirmed
present on unmodified origin/main via `git show HEAD`. Fixed by opening
a subshell with `(` instead, matching the `( ... ) &` backgrounding
pattern already used elsewhere in this same file (e.g.
_cmux_run_pr_probe_with_timeout, _cmux_prompt_command's pwd/git-branch
probes) — subshells support $! for the backgrounded PID same as job
groups do.
* refactor: shell integration speaks v2 JSON-RPC on the direct socket path
Step 3 of the v1-deletion sequence (see docs/v2-api-migration.md). Converts
the direct-socket sends in the zsh and bash shell-integration scripts from
v1 space-delimited lines to single-line v2 JSON-RPC frames, mirroring the
pattern the REMOTE-relay path in the same scripts already uses
(_cmux_relay_rpc "surface.report_tty" etc., added in PR #70's v2 parity
methods, commit 475aa2f).
Verbs converted (both scripts, kept behaviorally identical to each other):
- report_tty -> surface.report_tty {workspace_id, tty_name, surface_id?}
- report_shell_state -> surface.report_shell_state {workspace_id, surface_id, state}
- report_pwd -> surface.report_pwd {workspace_id, surface_id, path}
- report_git_branch -> surface.report_git_branch {workspace_id, surface_id, branch, dirty}
- clear_git_branch -> surface.clear_git_branch {workspace_id, surface_id}
- report_pr -> surface.report_pr {workspace_id, surface_id, number, url, state, branch}
- clear_pr -> surface.clear_pr {workspace_id, surface_id}
- ports_kick -> surface.ports_kick {workspace_id, surface_id?, reason}
workspace_id/surface_id are sourced from the same env vars the v1 fast path
and the v2 relay path already use (PROGRAMA_WORKSPACE_ID falling back to
PROGRAMA_TAB_ID, and PROGRAMA_PANEL_ID) via the existing _cmux_relay_workspace_id
helper. report_tty preserves the v1 tmux special case of omitting surface_id.
Both scripts reuse the existing _cmux_json_escape helper (already used by the
relay path) to safely escape quotes/backslashes/control chars in pwd paths and
branch names before interpolating them into the JSON frames.
Fire-and-forget semantics are unchanged: _cmux_send/_cmux_send_bg never read a
response today and still don't after this change; call sites that were
synchronous (report_git_branch/clear_git_branch/report_pr, which already run
inside an already-backgrounded subshell) stay synchronous, and call sites that
were backgrounded stay backgrounded.
The relay path itself is untouched.1 parent 816d154 commit 314e1df
2 files changed
Lines changed: 109 additions & 35 deletions
Lines changed: 55 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| |||
358 | 368 | | |
359 | 369 | | |
360 | 370 | | |
361 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
362 | 375 | | |
363 | 376 | | |
364 | | - | |
| 377 | + | |
365 | 378 | | |
| 379 | + | |
366 | 380 | | |
367 | | - | |
| 381 | + | |
368 | 382 | | |
369 | 383 | | |
370 | 384 | | |
| |||
398 | 412 | | |
399 | 413 | | |
400 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
401 | 419 | | |
402 | | - | |
| 420 | + | |
403 | 421 | | |
404 | 422 | | |
405 | 423 | | |
| |||
415 | 433 | | |
416 | 434 | | |
417 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
418 | 440 | | |
419 | | - | |
| 441 | + | |
420 | 442 | | |
421 | 443 | | |
422 | 444 | | |
| |||
427 | 449 | | |
428 | 450 | | |
429 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
430 | 455 | | |
431 | | - | |
| 456 | + | |
432 | 457 | | |
433 | 458 | | |
434 | 459 | | |
| |||
629 | 654 | | |
630 | 655 | | |
631 | 656 | | |
632 | | - | |
633 | | - | |
634 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
635 | 660 | | |
636 | 661 | | |
637 | 662 | | |
| |||
645 | 670 | | |
646 | 671 | | |
647 | 672 | | |
648 | | - | |
649 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
650 | 679 | | |
651 | 680 | | |
652 | 681 | | |
| |||
745 | 774 | | |
746 | 775 | | |
747 | 776 | | |
748 | | - | |
| 777 | + | |
749 | 778 | | |
750 | 779 | | |
751 | 780 | | |
| |||
913 | 942 | | |
914 | 943 | | |
915 | 944 | | |
916 | | - | |
917 | | - | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
918 | 950 | | |
919 | 951 | | |
920 | 952 | | |
| |||
963 | 995 | | |
964 | 996 | | |
965 | 997 | | |
966 | | - | |
| 998 | + | |
967 | 999 | | |
| 1000 | + | |
968 | 1001 | | |
969 | 1002 | | |
970 | 1003 | | |
971 | | - | |
972 | | - | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
973 | 1009 | | |
974 | | - | |
| 1010 | + | |
| 1011 | + | |
975 | 1012 | | |
976 | 1013 | | |
977 | 1014 | | |
| |||
Lines changed: 54 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
| |||
458 | 468 | | |
459 | 469 | | |
460 | 470 | | |
461 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
462 | 475 | | |
463 | 476 | | |
464 | | - | |
| 477 | + | |
465 | 478 | | |
| 479 | + | |
466 | 480 | | |
467 | | - | |
| 481 | + | |
468 | 482 | | |
469 | 483 | | |
470 | 484 | | |
| |||
496 | 510 | | |
497 | 511 | | |
498 | 512 | | |
499 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
500 | 518 | | |
501 | 519 | | |
502 | 520 | | |
| |||
510 | 528 | | |
511 | 529 | | |
512 | 530 | | |
513 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
514 | 536 | | |
515 | 537 | | |
516 | 538 | | |
| |||
526 | 548 | | |
527 | 549 | | |
528 | 550 | | |
529 | | - | |
| 551 | + | |
530 | 552 | | |
| 553 | + | |
531 | 554 | | |
532 | 555 | | |
533 | | - | |
534 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
535 | 561 | | |
536 | | - | |
| 562 | + | |
| 563 | + | |
537 | 564 | | |
538 | 565 | | |
539 | 566 | | |
540 | 567 | | |
541 | 568 | | |
542 | 569 | | |
543 | 570 | | |
544 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
545 | 575 | | |
546 | 576 | | |
547 | 577 | | |
| |||
742 | 772 | | |
743 | 773 | | |
744 | 774 | | |
745 | | - | |
746 | | - | |
747 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
748 | 778 | | |
749 | 779 | | |
750 | 780 | | |
| |||
758 | 788 | | |
759 | 789 | | |
760 | 790 | | |
761 | | - | |
762 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
763 | 797 | | |
764 | 798 | | |
765 | 799 | | |
| |||
1074 | 1108 | | |
1075 | 1109 | | |
1076 | 1110 | | |
1077 | | - | |
1078 | | - | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
1079 | 1116 | | |
1080 | 1117 | | |
1081 | 1118 | | |
| |||
0 commit comments