Skip to content

Tw 5660 reduce over engineering Patch 1#112

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

Tw 5660 reduce over engineering Patch 1#112
qasim-nylas merged 4 commits into
mainfrom
TW-5660-reduce-over-engineering-1

Conversation

@qasim-nylas

Copy link
Copy Markdown
Collaborator

No description provided.

…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).
…wnload

Unify the API timeout default and make it overridable per-install.

- domain.TimeoutAPI 90s -> 120s, matching httputil.DefaultClientTimeout (now
  derived from it as a single source of truth). Previously CLI commands were
  effectively capped at 90s by CreateContext while the client allowed 120s.
- Add api.timeout config key (Config.Timeout) and NYLAS_API_TIMEOUT env var,
  resolved via Config.ResolveAPITimeout (env > config > default; invalid or
  non-positive values fall back to the default). The previously-dead
  `nylas config set api.timeout` help text now works.
- nylas client ApplyConfig applies the resolved timeout to requestTimeout and
  swaps in a matching http.Client when non-default so a >120s override isn't
  clipped by the transport cap.
- common.CreateContext honors the resolved timeout via SetAPITimeout (atomic),
  set in GetNylasClient.

Also: point Slack file downloads at the shared 120s client and delete the
now-single-use domain.TimeoutDownload (15m), making Slack and email attachment
downloads consistent.

Tests: ResolveAPITimeout (env/config/default/invalid), CreateContext
(default + configured), ApplyConfig timeout wiring.
@qasim-nylas qasim-nylas requested a review from AaronDDM June 22, 2026 12:48
AaronDDM
AaronDDM previously approved these changes Jun 22, 2026

@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 👍

…used code

- Delete write-only internal/adapters/providers package and its client init()
  (Register was called but the factory map was never read)
- Remove unused CheckForUpdateAsync and now-dead domain import
- Replace status-code loop with slices.Contains; inline stringSliceContains
  as slices.ContainsFunc (TrimSpace semantics preserved)
- Delete dead DialogType type and constants
- Inline single-caller stripHTMLForQuote into stripHTMLForTUI

@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 adb23d2 into main Jun 22, 2026
7 checks passed
@qasim-nylas qasim-nylas deleted the TW-5660-reduce-over-engineering-1 branch June 22, 2026 14:02
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