Skip to content

feat(THU-708): upgrade tinfoil and enable prompt caching#1140

Open
arienemaiara wants to merge 2 commits into
mainfrom
THU-708/update-tinfoil-for-prompt-caching
Open

feat(THU-708): upgrade tinfoil and enable prompt caching#1140
arienemaiara wants to merge 2 commits into
mainfrom
THU-708/update-tinfoil-for-prompt-caching

Conversation

@arienemaiara

@arienemaiara arienemaiara commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator
  • bump tinfoil 1.1.4 -> 1.1.11 for userCacheSecret support
  • generate a per-device cache secret in localStorage; it only reaches the attested enclave, never our backend
  • pass the secret to both system and user SecureClient instances
  • clear the secret on identity teardown so a new cache namespace starts
cache.mov

- bump tinfoil 1.1.4 -> 1.1.11 for userCacheSecret support
- generate a per-device cache secret in localStorage; it only reaches
  the attested enclave, never our backend
- pass the secret to both system and user SecureClient instances
- clear the secret on identity teardown so a new cache namespace starts
Copilot AI review requested due to automatic review settings July 24, 2026 17:07
@arienemaiara arienemaiara self-assigned this Jul 24, 2026
@github-actions

Copy link
Copy Markdown

Semgrep Security Scan

No security issues found.

Comment thread src/lib/auth-token.ts Dismissed

Copilot AI 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.

Pull request overview

Upgrades the tinfoil SDK and wires in a per-device prompt-cache secret so Tinfoil prompt caching can be safely namespaced per device and reset on identity teardown.

Changes:

  • Bump tinfoil from ^1.1.4 to ^1.1.11 to support userCacheSecret.
  • Add getUserCacheSecret/clearUserCacheSecret localStorage helpers and corresponding unit tests.
  • Pass the per-device cache secret into both system and user SecureClient instances; clear it during identity teardown and test cleanup.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/testing-library.ts Clears the new cache secret between tests to prevent cross-test leakage.
src/lib/cleanup.ts Clears the cache secret during local identity teardown (clearLocalData).
src/lib/auth-token.ts Adds generation/storage/clearing of a per-device Tinfoil prompt-cache secret.
src/lib/auth-token.test.ts Adds test coverage for secret format, stability, and regeneration after clearing.
src/ai/fetch.ts Injects userCacheSecret into system/user Tinfoil SecureClient construction.
package.json Upgrades tinfoil dependency version.
bun.lock Updates lockfile to reflect the tinfoil upgrade and transitive dependency changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- the store already holds the bearer token, which grants more access
- SDK needs the plaintext string, so a wrapping key adds no protection
Copilot AI review requested due to automatic review settings July 24, 2026 17:13

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread src/lib/auth-token.ts
Comment on lines +59 to +68
export const getUserCacheSecret = (): string => {
const existing = localStorage.getItem(userCacheSecretKey)
if (existing) {
return existing
}
const bytes = crypto.getRandomValues(new Uint8Array(32))
const secret = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')
localStorage.setItem(userCacheSecretKey, secret)
return secret
}
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

Preview environment deployed 🚀

Service URL
Marketing / blog / docs https://thunderbolt-pr-1140.preview.thunderbolt.io
App https://app-pr-1140.preview.thunderbolt.io
API https://api-pr-1140.preview.thunderbolt.io
Keycloak https://auth-pr-1140.preview.thunderbolt.io
PowerSync https://powersync-pr-1140.preview.thunderbolt.io

Stack: preview-pr-1140 · Commit: 1c90e4eaa2007df33d6d3a3e6432c1c857fb55ed

Auto-destroys on PR close/merge. Login via the bundled Keycloak realm — demo@thunderbolt.io / demo by default.

@github-actions

Copy link
Copy Markdown

PR Metrics

Metric Value
Lines changed (prod code) +36 / -6
JS bundle size (gzipped) 🟢 644.9 KB → 644.8 KB (-80 B, -0.0%)
Test coverage 🟢 79.09% → 79.09% (+0.0%)
Performance (preview) Preview not ready — Render deploy may have timed out
Accessibility
Best Practices
SEO

Updated Fri, 24 Jul 2026 17:19:40 GMT · run #2431

@github-actions github-actions 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.

🔭 thunder-deep-review (advisory)

Reviewed the diff — no issues to report. ✅ Never approves, never requests changes, never gates merge.
head: 1c90e4eaa200 · mode: single · deferred 0 item(s) already reported by other bots (best-effort dedup)

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.

4 participants