fix(ci): prevent crash when ci view used in non-interactive environments
Fixes #8145 (closed) where glab ci view crashed with "close of nil channel" when run by AI agents or in non-TTY environments.
Problem
The TUI command requires an interactive terminal but was attempting to initialize the screen anyway, leading to panics during cleanup when the screen wasn't fully initialized. This issue was discovered when AI agents like "opencode" tried to use the command programmatically.
Changes
- Add early TTY check with helpful error message suggesting alternatives (ci status, ci get, ci trace)
- Initialize tcell screen explicitly and ensure proper cleanup with defer
- Add Interactive annotation to mark TUI commands
- Exclude interactive commands from MCP tools so AI agents don't attempt to use them
Test Plan
-
Build and test
glab ci viewin non-TTY environment - Verify error message is clear and helpful
- Verify pre-commit hooks pass
- Confirm interactive commands are excluded from MCP
Before
$ glab ci view
2026/02/04 16:11:01 close of nil channel
[panic stack trace]
After
$ glab ci view
ERROR: Ci view requires an interactive terminal (TTY).
For non-interactive use, try:
- 'glab ci status' to check pipeline status
- 'glab ci get' to view pipeline details
- 'glab ci trace' to view job logs