Skip to content

fix(tui): explain a branch that became unusable mid-session (#176) - #214

Merged
thomaschristory merged 2 commits into
mainfrom
feat/176-tui-branch-unusable
Oct 25, 2026
Merged

thomaschristory merged 2 commits into
mainfrom
feat/176-tui-branch-unusable

Conversation

@thomaschristory

Copy link
Copy Markdown
Owner

Summary

If the active branch is merged, archived or deleted while nsc tui is open, NetBox Branching rejects later requests with a plain-text 400 (Selected branch is not ready. / Invalid branch identifier). The TUI used to show that as a bare API 400. Now it says branch '<name>' is no longer usable (status: …) and points the user back to main.

  • New nsc/branching/unusable.py classifier (branch_unusable_error). It matches only the Branching middleware's exact plain-text bodies, and only while a branch is active, so validation 400s look the same as before.
  • New BranchUnusableError in nsc/branching/errors.py.
  • The branch-aware message is used by: list first load and load-more, detail save and delete, edit-form save, record picker, bulk-edit summary (apply_bulk(describe=...)), and global search. Global search stops at the first such failure.
  • Saved searches: NativeSavedFilterStore now takes the active branch. The TUI app and the --saved CLI path pass it in. When a save, load or delete falls back to config.yaml, the warning names the branch as the cause. This includes the object-type lookup, which used to fail silently.
  • Docs: docs/guides/interactive-tui.md and docs/guides/branching.md. CHANGELOG entry under Unreleased.

Closes #176

Test plan

  • just test: 1692 passed, 1 skipped
  • just lint: ruff, ruff format, mypy --strict all clean
  • Classifier unit tests (tests/branching/test_unusable.py)
  • Store tests: list, save and delete on a dead branch, the object-type lookup failing on a branch, the lookup failing off a branch (stays quiet), and a validation 400 on a branch (keeps the generic text)
  • Pilot tests for every TUI call site: list load and load-more, detail save and delete, edit-form save, bulk-edit summary, record picker, global search. I checked that they fail when the branch wiring is removed.

https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb

NetBox Branching answers requests for a merged, archived or deleted branch
with a plain-text 400. A framework-free classifier in nsc.branching.unusable
recognizes exactly those middleware bodies (only while a branch is active)
and the TUI error paths render them as "branch 'X' is no longer usable
(status: ...)" instead of a bare API 400. Global search stops at the first
such failure; bulk-edit failures carry the same message. Other 400s render
unchanged.

Claude-Session: https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb
…#176)

The saved-filter store reported a branch-state 400 as a bare
'NetBox API 400 on ...' and silently swallowed it during the object-type
lookup, so saves quietly diverted to config.yaml. The store now takes the
active branch (wired by the TUI app and the --saved CLI path) and reports
'branch <name> is no longer usable' through the branch-state classifier.

Adds pilot tests for every branch-aware TUI call site: detail save and
delete, edit-form save, bulk-edit summary, record picker and list
load-more.

Claude-Session: https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb
@thomaschristory

Copy link
Copy Markdown
Owner Author

Rebased onto main after #213 (CHANGELOG conflict resolved). Tests + lint green locally.

@thomaschristory
thomaschristory force-pushed the feat/176-tui-branch-unusable branch from 3d6882a to 80dde63 Compare October 25, 2026 10:50
@thomaschristory
thomaschristory merged commit e8f1af6 into main Oct 25, 2026
15 checks passed
@thomaschristory
thomaschristory deleted the feat/176-tui-branch-unusable branch October 25, 2026 10:57
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.

TUI: handle a branch becoming unusable mid-session

1 participant