Repository navigation
Commit 7b21606
fix: [AI-9171] address review — fix the TUI's copy of the same bug
Review round on PR #1314. The important one is sahrizvi's: the TUI had the
identical defect and this PR did not touch it.
**The TUI carried the same bug.** `createAndBindInline` called `createAndBind`
unconditionally, so on an already-linked project the server 409'd before
creating anything and the rebind below was unreachable — exactly what this PR
fixes in `link.ts`. Its `rebindFrom` doc asserted the assumption the bug rested
on ("createAndBind succeeds but leaves the binding pointing at the OLD
workspace"); that is corrected too. Both surfaces now make the same split, so
the CLI and the TUI cannot disagree about what that row does.
**`Number()` coerced its way past the id guard.** `Number.isSafeInteger(Number(x))`
accepts `true` as 1, `"7"` as 7 and `[5]` as 5, so a malformed body would have
rebound the project to workspace 1 rather than failing. The type check now runs
before the arithmetic, and it throws a typed `WorkspaceApiError` rather than a
bare `Error`, matching every other failure in that module.
**The account is pinned across the two-step.** Create and rebind resolve
credentials independently, so a re-login in between created the workspace on one
tenant and sent the rebind to another with an id local to the first. Both
surfaces capture the account before the create and refuse the rebind if it
changed. The API key is deliberately not part of the fingerprint: rotating a key
for the same user on the same tenant is not an identity change.
**The rebind's own binding row is what gets cached.** The response was
discarded and the local identifiers cached instead, so a path-keyed row rebound
through `/by-path` was cached carrying a `repo_remote` the server never stored.
**The 409 message no longer guesses.** It was written for the bind path and
claimed a binding race; the unbound create sends no identifiers and cannot
produce one. Split by which call actually ran.
**`created` is a discriminated union** rather than one shape with optional
halves, so `binding` and `manage_url` are only reachable on the path that has
them.
Not changed, with reason: cubic asked for the nested `{datamate:{id}}` shape to
be accepted. `POST /datamates/` declares `response_model=CreateDatamateResponse`
(`{id: int}`) and FastAPI enforces it, so that shape cannot come back from this
endpoint. The strict guard above turns a contract break into a loud failure,
which is the better outcome than silently accepting an unexpected shape.
Tests: `create-then-rebind.test.ts` asserts the *sequence of endpoints* for both
surfaces, because the bug was never in a payload — it was in which request got
sent. Covers unlinked, already-linked, a failed rebind (non-zero exit / error
toast, not a claimed success), and a 409 that must not reach the rebind. Each
one fails if the corresponding fix is reverted.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent 2efd7f3 commit 7b21606
5 files changed
Lines changed: 422 additions & 40 deletions
File tree
- packages/opencode
- src
- altimate/workspace
- cli/cmd
- plugin/tui/altimate
- test/altimate/workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
416 | 438 | | |
417 | 439 | | |
418 | 440 | | |
| |||
428 | 450 | | |
429 | 451 | | |
430 | 452 | | |
431 | | - | |
432 | | - | |
433 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
434 | 465 | | |
435 | 466 | | |
436 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
481 | 485 | | |
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
488 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
489 | 506 | | |
490 | 507 | | |
491 | 508 | | |
| |||
500 | 517 | | |
501 | 518 | | |
502 | 519 | | |
503 | | - | |
| 520 | + | |
504 | 521 | | |
505 | | - | |
| 522 | + | |
| 523 | + | |
506 | 524 | | |
507 | 525 | | |
508 | 526 | | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
513 | 532 | | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
519 | 545 | | |
520 | 546 | | |
521 | 547 | | |
| |||
531 | 557 | | |
532 | 558 | | |
533 | 559 | | |
| 560 | + | |
534 | 561 | | |
535 | 562 | | |
536 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
537 | 577 | | |
538 | | - | |
| 578 | + | |
539 | 579 | | |
540 | 580 | | |
541 | 581 | | |
542 | 582 | | |
543 | 583 | | |
| 584 | + | |
544 | 585 | | |
545 | 586 | | |
546 | 587 | | |
| |||
554 | 595 | | |
555 | 596 | | |
556 | 597 | | |
557 | | - | |
558 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
559 | 604 | | |
560 | 605 | | |
561 | 606 | | |
562 | | - | |
563 | | - | |
| 607 | + | |
| 608 | + | |
564 | 609 | | |
565 | 610 | | |
566 | 611 | | |
567 | 612 | | |
568 | 613 | | |
569 | 614 | | |
570 | | - | |
| 615 | + | |
571 | 616 | | |
572 | 617 | | |
573 | 618 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
493 | 494 | | |
494 | 495 | | |
495 | 496 | | |
496 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
497 | 500 | | |
498 | 501 | | |
499 | 502 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
504 | 509 | | |
505 | 510 | | |
506 | 511 | | |
507 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
508 | 527 | | |
509 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
510 | 535 | | |
511 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
512 | 539 | | |
513 | 540 | | |
514 | 541 | | |
| |||
522 | 549 | | |
523 | 550 | | |
524 | 551 | | |
| 552 | + | |
525 | 553 | | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
531 | 565 | | |
532 | | - | |
| 566 | + | |
533 | 567 | | |
534 | 568 | | |
535 | 569 | | |
536 | 570 | | |
537 | 571 | | |
| 572 | + | |
538 | 573 | | |
539 | 574 | | |
540 | 575 | | |
| |||
545 | 580 | | |
546 | 581 | | |
547 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
548 | 587 | | |
549 | 588 | | |
550 | 589 | | |
| |||
557 | 596 | | |
558 | 597 | | |
559 | 598 | | |
560 | | - | |
561 | | - | |
| 599 | + | |
| 600 | + | |
562 | 601 | | |
563 | 602 | | |
564 | 603 | | |
| |||
0 commit comments