Skip to content

feat(conversations): metadata list + single-conversation GET - #12

Merged
1bcMax merged 2 commits into
masterfrom
feat/conversation-meta
Jun 6, 2026
Merged

feat(conversations): metadata list + single-conversation GET#12
1bcMax merged 2 commits into
masterfrom
feat/conversation-meta

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Collaborator

Scales the /try conversation 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() + ConversationMeta type.

Backward compatible

GET without ?meta=1 still 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)

  • A per-wallet index file so meta avoids reading every object from GCS (current impl reads objects then strips bodies — saves client bandwidth, not yet GCS reads).
  • Extract inlined data: images to separate blobs (agent-side strip before upload).

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.
@1bcMax
1bcMax merged commit bbda7b5 into master Jun 6, 2026
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.

1 participant