Skip to content

Enable the SDK's ETag response cache - #374

Merged
jeremy merged 2 commits into
mainfrom
cli-enable-cache
Sep 1, 2026
Merged

Enable the SDK's ETag response cache#374
jeremy merged 2 commits into
mainfrom
cli-enable-cache

Conversation

@jeremy

@jeremy jeremy commented Sep 1, 2026

Copy link
Copy Markdown
Member

The CLI has run with CacheEnabled: false since the SDK migration (#23), so no request ever revalidated with If-None-Match and every read refetched full bodies the server had already told us hadn't changed — while HEY serves ETags broadly and answers conditionals with 304s.

The SDK cache is a revalidation cache: every read still asks the server, conditionally, and only a 304 is answered from disk — so enabling it can never serve stale mail. Specifics:

  • The cache lives under the CLI's cache directory at hey-cli/http (XDG-aware); when no cache location resolves, caching stays off.
  • Logout drops the cache, so cached mail does not outlive the credentials that fetched it.
  • Cookie-session auth never caches (the SDK keys entries by the Authorization header), so nothing changes there.

Safe to merge independently of the SDK: the cache is inert where ETags aren't wired. Generated operations start revalidating once the SDK dependency carries basecamp/hey-sdk#140; until then the cache covers the hand-written request paths.

Card: https://app.basecamp.com/2914079/buckets/48521764/card_tables/cards/10240004704

TMPDIR=/tmp/t make check green.


Summary by cubic

Enables the SDK's ETag response cache so reads revalidate with If-None-Match and serve 304s from disk instead of refetching unchanged bodies. Replacing credentials—logout or login over standing credentials—clears the cache, so cached mail never outlives the credentials that fetched it.

  • The cache lives at hey-cli/http under the CLI's XDG-aware cache directory; when no cache location resolves, caching stays off.
  • Cookie-session auth is unaffected because the SDK keys cache entries by the Authorization header.
  • Generated operations start revalidating once the SDK dependency carries basecamp/hey-sdk#140; until then, the cache covers the hand-written request paths only.

Written for commit 1c79b05. Summary will update on new commits.

Review in cubic

The CLI has run with CacheEnabled: false since the SDK migration (#23),
so no request ever revalidated with If-None-Match and every read
refetched full bodies the server had already told us hadn't changed.

The SDK cache is a revalidation cache: every read still asks the server,
conditionally, and only a 304 is answered from disk — so enabling it can
never serve stale mail. The cache lives under the CLI's cache directory
at hey-cli/http, and logout drops it so cached mail does not outlive the
credentials that fetched it. When no cache location resolves, caching
stays off.

Generated operations start revalidating once the SDK dependency carries
basecamp/hey-sdk#140; until then the cache covers the hand-written
request paths and is inert elsewhere.
Copilot AI balanced review requested due to automatic review settings September 1, 2026 07:14
@jeremy
jeremy requested a review from a team as a code owner September 1, 2026 07:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T07:47:00.932005Z 1c79b05 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enables SDK ETag revalidation caching and removes cached responses during logout.

Changes:

  • Configures an XDG-aware HTTP cache.
  • Clears cached mail on logout.
  • Adds cache configuration and logout tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/cmd/sdk.go Enables and manages the SDK cache.
internal/cmd/auth.go Clears the cache during logout.
internal/cmd/sdk_cache_test.go Tests cache setup and cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/cmd/sdk.go
Comment thread internal/cmd/sdk.go Outdated
Comment thread internal/cmd/auth.go Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/cmd/sdk.go Outdated
Comment thread internal/cmd/sdk.go
Comment thread internal/cmd/sdk.go Outdated
Comment thread internal/cmd/sdk.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c944997ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/sdk.go
Comment thread internal/cmd/sdk.go Outdated
Comment thread internal/cmd/sdk.go
Login over standing credentials — token, cookie, or OAuth, setup's flow
included — replaces them and orphans whatever the old ones cached, so the
replacement clears the cache without waiting for a logout. A clear that
fails no longer vanishes: the warning names the directory left to remove
by hand, after the credential change it trailed has already happened.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c79b05e2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/sdk.go
@jeremy
jeremy merged commit e409980 into main Sep 1, 2026
23 checks passed
@jeremy
jeremy deleted the cli-enable-cache branch September 1, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants