feat(conversations): metadata list + single-conversation GET - #12
Merged
Conversation
Scales the /try conversation store for clients with many/large chats: - GET /api/try/conversations?meta=1 → lightweight metadata only (id/title/createdAt/updatedAt/messageCount), no message bodies, so the list renders without pulling every message + inlined image each load. - GET /api/try/conversations/[id] → fetch one full conversation, for lazy-loading on open. - franklin-store: listConversationMeta() + ConversationMeta type. Backward compatible: GET without ?meta=1 still returns full conversations, so existing clients (incl. the desktop wallet-synced history) are unaffected.
Addresses the pre-landing review on PR #12. Correctness / data safety: - getConversation no longer conflates store failures with not-found: GCS outages and corrupt objects now surface as 500, only genuine 404/ENOENT return null. Drops the exists() pre-check (one GCS round trip per open). - listConversations fails loud on a transport error (was a silent partial 200 that a sync client could read as deletions); only corrupt JSON is skipped + logged. - PUT validates conversation shape/types and stamps a server-authoritative updatedAt, so a client-sent NaN/string can't poison the list sort. Message objects are preserved as-is (images[]/music/activity pass through). - Reject non-canonical conversation ids (400) instead of silently normalizing them to a shared storage key (was within-wallet overwrite/ delete via safeId collisions). Security: - All /api/try/* responses now send Cache-Control: private, no-store + Vary: Cookie via a shared jsonPrivate() helper — a CDN can no longer cache one wallet's history and serve it to another. - 500s return a generic "Store error" and log server-side; raw GCS messages (bucket/project/object path with wallet) are no longer leaked. - session: reject missing/NaN exp (was never-expiring), validate EVM address shape, add an audience claim (legacy tokens still accepted). Stability: - Cap GCS download concurrency at 8 and bound conversation size (24MB) and message count, so a large/abusive history can't OOM the instance via ?meta=1. - ?meta accepts "1" or "true"; optional ?limit (1..200) bounds response size. - USE_LOCAL guards on K_SERVICE so a non-prod NODE_ENV on Cloud Run can't silently write to ephemeral container disk.
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.
Scales the
/tryconversation store for clients with many/large chats (e.g. the desktop's wallet-synced history).Changes
GET /api/try/conversations?meta=1→ lightweight metadata only (id/title/createdAt/updatedAt/messageCount), no message bodies. Lets a client render the conversation list without downloading every message + inlined base64 image on each load.GET /api/try/conversations/[id]→ fetch one full conversation, for lazy-loading on open.franklin-store:listConversationMeta()+ConversationMetatype.Backward compatible
GETwithout?meta=1still returns full conversations, so existing clients (web/try, and the desktop wallet-synced history) keep working unchanged. This is purely additive.Follow-ups (not in this PR)
metaavoids reading every object from GCS (current impl reads objects then strips bodies — saves client bandwidth, not yet GCS reads).data:images to separate blobs (agent-side strip before upload).