Repository navigation
refactor: stop refining failed forge calls and missing nu/pwsh - #4436
Conversation
Applies AGENTS.md "Other Tools Own Their Conventions" to what #4106 left: - CI status: a failed gh/glab/az/tea call now shows the error indicator. The classifier that matched English stderr (rate limit, 403, connection, ...) to decide between an error and a blank "no CI" cell is gone; Gitea reads only whether the HTTP status is an error. Lookups by commit SHA (GitHub check runs, Gitea combined status) now run only when a remote-tracking ref contains the head, since the forge answers an unpushed commit with an error. - PowerShell on Unix: no `pwsh` to ask means no profile, not a guessed `~/.config/powershell` one. - Nushell: no `nu` to ask means no autoload candidates, not a reconstruction of Nushell's data-dir rule. Behavior changes: a gh/glab/az installed but not logged in now shows the error indicator under `wt list --full` rather than a blank cell; Gitea 4xx responses show it too. Install and uninstall skip PowerShell and Nushell when their tool can't be queried, so a wrapper stranded after uninstalling nu is no longer found. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
A gh/glab/tea/az that is installed but not logged in now puts ⚠ on every CI-fetched surface, not only under wt list --full. statusline_options builds its gates with show_full: true, so wt list statusline fetches CI status on every redraw. A user who has gh installed but never ran gh auth login, or who isn't logged in to the GHE host this repo uses, gets a permanent yellow ⚠ in their prompt or Claude Code statusline. Retrying won't clear it, and the statusline doesn't say why it's there.
The rule this PR applies points the other way for this case. Other Tools Own Their Conventions in AGENTS.md names gh auth token --hostname as how worktrunk asks whether a host is authenticated, and it says a tool with nothing to integrate with needs no fallback. Not being logged in to the remote's host reads like the not-installed case, which gets a blank cell. The helpers already exist and stay local: remote_ref::github::is_authed_for(host), remote_ref::gitea::is_authed_for(host), plus the glab auth status --hostname / az account show probes in CiToolsStatus::detect. If detect_ci checked them next to is_tool_available, ⚠ would mean what the legend says, a fetch that failed. That costs one local probe per platform per process. Showing ⚠ is also defensible, since it surfaces the problem, but the call should take the statusline into account, so I'm leaving it for you rather than approving.
…pletion path only completion_path answered for every shell, but only fish installs a completion file, so the other arms were dead code: fish_completion_path replaces it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
Two doc comments in src/shell/paths.rs still name the removed completion_path, and neither is in the diff:
nu_dirsjustifies its memoisation by saying install resolves "the write target (completion_path) and the installed-state candidates (config_paths)".nushell_autoload_candidatesis now the only caller, so the doc should give whatever reason still holds, such as repeatedconfig_pathslookups in one process.fish_config_dirsays the completion goes through it viacompletion_path. That should now sayfish_completion_path.
I can push that edit if you'd like.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Since #4436, any failed forge call shows ⚠. That includes a CLI that is installed but not logged in, which then puts a permanent ⚠ in `wt list --full`, the shell prompt, and the Claude Code statusline. This change leaves the cell blank when the CLI holds no login for the forge's host, and keeps ⚠ for a failure from a CLI that does (offline, rate limit, expired token). Each CLI answers from its own local state, so a lost connection never reads as logged out: - **GitHub**: `gh` exits with its documented code 4 when it has no login for the host it resolved for the request. The backend reads that exit code, so SSH host aliases resolve the way `gh` resolves them. - **GitLab / Gitea / Azure DevOps**: after a failed call, `remote_ref::is_authed_for(forge, host)` asks `glab config get token --host`, `tea logins list --output json`, or `az account show`, for the `forge.hostname` if configured, else the remote's host. The answer is cached per forge and host for the process. `wt config show --full` uses the same check for the repo's host and names that host in its warning. It replaces `CiToolsStatus`, which probed all four CLIs to report one, and asked `gh auth status` / `glab auth status`, which contact the server and accept a login for any host. `tea`'s host-agnostic `has_any_login` is gone with it. Behavior changes: - `wt list --full` / statusline: a CLI with no login for the host leaves the CI cell blank instead of ⚠. The legend now lists that under blank, and ⚠'s examples say "expired login". - `wt config show --full`: a login for another host no longer counts, and the warning says which host it checked (`gh installed but not authenticated for github.com`). Known limits: a GitLab or Gitea remote through an SSH host alias is checked under the alias, so a failure there shows blank unless `forge.hostname` names the real host; Azure DevOps counts only an `az login`, not a PAT from `az devops login`. Tests: the failed-list test now covers logged-in and logged-out cases for `gh` (exit 1 vs 4) and `glab` (token vs none); the `tea` CI mocks hold a login for the test host; the `tea` login-discovery test adds a login for another host. Follows #4436. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
After #4436 removed the `dirs::data_dir()` fallbacks, the only remaining use of `dirs` is `dirs::document_dir()` inside `#[cfg(windows)]` in `src/shell/paths.rs` (`powershell_profile_paths`). The nightly `check-unused-dependencies` job runs `cargo udeps --all-targets` on Linux, and in [run 38353472092](https://github.com/max-sixty/worktrunk/actions/runs/38353472092) it reports `dirs` as unused. This PR moves `dirs` into a `[target.'cfg(windows)'.dependencies]` table so Linux and macOS builds no longer pull it in. `Cargo.lock` is unchanged. I couldn't run `cargo udeps` locally because it needs a nightly toolchain. The Windows build in this PR's CI confirms that `dirs` still resolves where it's used. The same nightly run had a second, unrelated failure, a race in `test_promote_bare_repo_with_worktrees`. #4466 fixes it separately. Refs #4464 — automated triage Co-authored-by: worktrunk-bot <[email protected]>
Applies
AGENTS.md's Other Tools Own Their Conventions (#4435) to what #4106 left: where worktrunk refined how it handles a case outside standard use, stop handling the case.CI status: a failed forge call shows the error indicator. The classifier that searched
gh/glab/az/teaoutput for English phrases ("rate limit", "403", "connection", …) to choose between ⚠ and a blank "no CI" cell is deleted. Any failed call now shows ⚠. Gitea reads only whether the HTTP status is an error, not which one. The two lookups by commit SHA (GitHub check runs, Gitea combined status) now run only when some remote-tracking ref contains the head, since the forge answers a commit it doesn't have with an error and ordinary unpushed work would otherwise show ⚠. GitLab and Azure look pipelines up by branch and are unchanged.PowerShell on Unix. When
pwshcan't be queried there is no PowerShell profile, rather than a guessed~/.config/powershellone (left by #4422).Nushell. When
nucan't be queried there are no autoload candidates, rather than a reconstruction of Nushell's data-dir rule. Install can't write into a legacy directory, since the candidate list is empty.Behavior changes:
gh/glab/azinstalled but not logged in now shows ⚠ underwt list --fullinstead of a blank cell. Detection checks that the tool is installed, andwt config showreports that it isn't logged in. The ⚠ legend now names "not logged in".wt config shell install powershell(ornu) without the tool fails with "No shell config files found", and uninstall no longer finds a wrapper left behind afternuwas removed.Fish's completion path.
Shell::completion_pathanswered for every shell, but only fish installs a completion file; its other arms, including the Nushell one this change touched, were dead.shell::fish_completion_pathreplaces it.Tests: the retriable-classifier unit tests are gone, and the Gitea test that only distinguished a blanked 500 body. Mocks now answer for branches other than the one under test, since those would otherwise show ⚠. New tests: a failed
gh pr list/glab mr listshows ⚠; an unpushed head skips the GitHub and Gitea lookups by SHA, each with a pushed control. Shell unit tests and the PowerShell integration tests no longer depend on a realnuorpwsh; they pass with only/usr/bin:/binonPATH. Full integration and unit suites pass locally.Ref #4106.