Skip to content

TW-5660: reduce CLI over-engineering; fix default-grant reconciliation & quiet flow#111

Merged
qasim-nylas merged 1 commit into
mainfrom
TW-5660-reduce-over-engineering
Jun 22, 2026
Merged

TW-5660: reduce CLI over-engineering; fix default-grant reconciliation & quiet flow#111
qasim-nylas merged 1 commit into
mainfrom
TW-5660-reduce-over-engineering

Conversation

@qasim-nylas

Copy link
Copy Markdown
Collaborator

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

  • 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 — the one intentional exception.
  • nylas/client.go uses the shared client; attachment downloads are now bound by the 120s default (the server-side timeout is 120s).
  • userAgentTransport clones the request before setting User-Agent (honors the http.RoundTripper no-mutation contract; avoids a retry/shared-request race).
  • 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

  • Misleading default-grant errors. email list (and friends) showed a confusing Resource not found, E004 when the stored default grant was stale, while auth list still showed a default — because the default lived in two stores (grant cache grants.json = authoritative, legacy config.yaml) that were read inconsistently.
    • WithClient now 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.
  • --quiet flow. Wired the cobra --quiet flag into process-wide quiet mode via auditPreRun; quietMode is now atomic.Bool (read by spinner/progress goroutines).

Tests

  • Added coverage for the grant write-back/self-heal paths.
  • Removed two flaky Slack integration tests (users list repeatedly tripping the Slack API rate limit, Code E007).

Verification

make ci-full green — all quality checks + unit/race + integration tests pass (exit 0). Reviewed with Claude + Codex review loop until both clean.

Related docs

…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).
@qasim-nylas qasim-nylas requested a review from AaronDDM June 22, 2026 06:04

@AaronDDM AaronDDM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@qasim-nylas qasim-nylas merged commit 298d1d7 into main Jun 22, 2026
7 checks passed
@qasim-nylas qasim-nylas deleted the TW-5660-reduce-over-engineering branch June 22, 2026 12:23
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.

2 participants