TW-5660: reduce CLI over-engineering; fix default-grant reconciliation & quiet flow#111
Merged
Merged
Conversation
…n & quiet flow
Repo-wide over-engineering cleanup plus two correctness fixes surfaced along
the way. Net: 90 files, +398/-6092.
HTTP client consolidation
- Single shared httputil.DefaultClient (120s timeout + nylas-cli User-Agent)
replaces the ad-hoc &http.Client{} literals; dashboard keeps its own DPoP
(non-redirect) client. nylas/client.go uses the shared client; attachment
downloads are bound by the 120s default. userAgentTransport clones the
request before setting User-Agent (RoundTripper no-mutation contract).
- httputil.NewServer centralizes server timeouts; air/ui/studio/chat migrated.
Dead-code removal (~6k lines)
- pattern_learner, config/validation.go, ports/utilities.go, ports/templates.go,
adapters/utilities/mock.go, internal/testutil/*, and assorted dead
helpers/flags/timeout constants.
Fixes
- Default grant: validate the stored default before use and self-heal a stale
pointer with a clear "select a grant" error instead of a confusing 404.
auth list (ListGrants) now reconciles the default across the grant cache and
config — writing a still-live default back into the cache so every command
agrees, clearing it from both stores when dead.
- --quiet: wire the cobra flag into process-wide quiet mode via auditPreRun;
quietMode is now atomic.Bool (read by spinner/progress goroutines).
Tests
- Remove two flaky Slack integration tests (users list rate-limit, E007).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Repo-wide over-engineering cleanup (ponytail audit passes) plus two correctness fixes surfaced along the way. Net: 90 files, +398 / −6092.
HTTP client consolidation
httputil.DefaultClient(120s timeout +nylas-cliUser-Agent) replaces the ad-hoc&http.Client{}literals. Dashboard keeps its own DPoP (non-redirect) client — the one intentional exception.nylas/client.gouses the shared client; attachment downloads are now bound by the 120s default (the server-side timeout is 120s).userAgentTransportclones the request before settingUser-Agent(honors thehttp.RoundTripperno-mutation contract; avoids a retry/shared-request race).httputil.NewServercentralizes server timeouts;air/ui/studio/chatmigrated.Dead-code removal (~6k lines)
pattern_learner*,config/validation.go,ports/utilities.go,ports/templates.go,adapters/utilities/mock.go,internal/testutil/*, and assorted dead helpers / flags / timeout constants.Fixes
email list(and friends) showed a confusingResource not found, E004when the stored default grant was stale, whileauth liststill showed a default — because the default lived in two stores (grant cachegrants.json= authoritative, legacyconfig.yaml) that were read inconsistently.WithClientnow validates the stored default before use and self-heals a stale pointer with a clear, actionable error.auth list(ListGrants) reconciles the default across both stores: a still-live default is written back into the cache so every command agrees; a dead default is cleared from both.--quietflow. Wired the cobra--quietflag into process-wide quiet mode viaauditPreRun;quietModeis nowatomic.Bool(read by spinner/progress goroutines).Tests
users listrepeatedly tripping the Slack API rate limit, Code E007).Verification
make ci-fullgreen — all quality checks + unit/race + integration tests pass (exit 0). Reviewed with Claude + Codex review loop until both clean.Related docs