Skip to content

feat(a2ui-playground): share whole conversation instead of final result#2795

Merged
PupilTong merged 2 commits into
lynx-family:mainfrom
PupilTong:claude/strange-mclaren-dd0e37
Jun 5, 2026
Merged

feat(a2ui-playground): share whole conversation instead of final result#2795
PupilTong merged 2 commits into
lynx-family:mainfrom
PupilTong:claude/strange-mclaren-dd0e37

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Jun 4, 2026

The per-conversation Share button used to copy a render.html link that only showed the final generated UI. It now serializes the entire conversation (transcript + data-model snapshot), uploads it via the existing Supabase payload endpoint, and builds an ?importConv=<url> link. Opening that link rehydrates the conversation into the recipient's playground as a fresh local conversation, so they can read every prompt -> result turn and continue chatting from there.

The shared document keeps each message's content and the snapshot dataModel -- exactly what the agent needs to restore its ConversationContext (history + a dataModel system message) on the next turn. The redundant previewMessages render cache is dropped and rebuilt from history on import to stay under the server body-size limit.

Changes:

  • storage/sharedConversation.ts (new): SharedConversationDoc, serializeConversation, isSharedConversationDoc
  • utils/shareConversation.ts (new): publishConversation, buildConversationShareUrl, import-param helpers
  • storage/conversationRepo.ts: importConversation()
  • hooks/useConversation.ts: importShared()
  • pages/AIChatPage.tsx: rewritten share handler + one-time import effect
  • components/ConversationListPanel.tsx: relabel share button
image

Summary by CodeRabbit

Release Notes

  • New Features
    • Share complete conversations with others via shareable links
    • Automatically import shared conversations when opening shared links
    • Updated share button tooltip text for improved clarity

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

The per-conversation Share button used to copy a render.html link that
only showed the final generated UI. It now serializes the entire
conversation (transcript + data-model snapshot), uploads it via the
existing Supabase payload endpoint, and builds an `?importConv=<url>`
link. Opening that link rehydrates the conversation into the recipient's
playground as a fresh local conversation, so they can read every
prompt -> result turn and continue chatting from there.

The shared document keeps each message's content and the snapshot
dataModel -- exactly what the agent needs to restore its
ConversationContext (history + a dataModel system message) on the next
turn. The redundant previewMessages render cache is dropped and rebuilt
from history on import to stay under the server body-size limit.

Changes:
- storage/sharedConversation.ts (new): SharedConversationDoc,
  serializeConversation, isSharedConversationDoc
- utils/shareConversation.ts (new): publishConversation,
  buildConversationShareUrl, import-param helpers
- storage/conversationRepo.ts: importConversation()
- hooks/useConversation.ts: importShared()
- pages/AIChatPage.tsx: rewritten share handler + one-time import effect
- components/ConversationListPanel.tsx: relabel share button
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

⚠️ No Changeset found

Latest commit: 308e8a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@PupilTong PupilTong self-assigned this Jun 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3eeac98b-5286-418b-b381-bc166f36ac1c

📥 Commits

Reviewing files that changed from the base of the PR and between 0c27ba2 and 308e8a9.

📒 Files selected for processing (4)
  • packages/genui/a2ui-playground/src/hooks/useConversation.ts
  • packages/genui/a2ui-playground/src/storage/conversationRepo.ts
  • packages/genui/a2ui-playground/src/storage/sharedConversation.ts
  • packages/genui/a2ui-playground/src/utils/shareConversation.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/genui/a2ui-playground/src/storage/conversationRepo.ts
  • packages/genui/a2ui-playground/src/utils/shareConversation.ts
  • packages/genui/a2ui-playground/src/hooks/useConversation.ts
  • packages/genui/a2ui-playground/src/storage/sharedConversation.ts

📝 Walkthrough

Walkthrough

Implements full conversation sharing: a versioned shared document format, serialization and publish utilities, repository import to persist shared docs, a new importShared method on the conversation hook, AIChatPage share/import flow changes (including auto-import via query param), and a share-button tooltip update.

Changes

Shared Conversation Import and Export

Layer / File(s) Summary
Shared Conversation Data Contract
packages/genui/a2ui-playground/src/storage/sharedConversation.ts
Defines versioned SharedConversationDoc with message and snapshot types, serializeConversation to convert conversation records, and isSharedConversationDoc runtime validator.
Import / Export Utilities & Repo Import
packages/genui/a2ui-playground/src/utils/shareConversation.ts, packages/genui/a2ui-playground/src/storage/conversationRepo.ts
Adds publishConversation, buildConversationShareUrl, readImportConversationParam, clearImportConversationParam, and IMPORT_CONVERSATION_PARAM; adds previewTextFromSharedMessages and importConversation to persist a shared doc as a new local conversation with resequenced messages.
Hook Integration: importShared
packages/genui/a2ui-playground/src/hooks/useConversation.ts
Adds importShared(doc: SharedConversationDoc): Promise<string> to the hook, handling both in-memory and persisted import paths and exposing it in the hook return.
Page-Level Share and Auto-Import Flow
packages/genui/a2ui-playground/src/pages/AIChatPage.tsx
Rewrites shareConversation to serialize & publish full conversations and build an import link; adds a one-time effect to auto-import shared conversations from a query param and clears the param after import.
Share Button Tooltip Update
packages/genui/a2ui-playground/src/components/ConversationListPanel.tsx
Changes share button title from "Copy share link" to "Copy conversation link".

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • lynx-family/lynx-stack#2770: Adds the onShare Share button UI wired to copy a render.html link, which this PR replaces with conversation document sharing.

Suggested reviewers

  • Sherry-hue
  • HuJean

"🐰 I hopped a doc through tree and vine,
serialized chats, each message in line.
Publish, import, a link in a blink—
Conversations shared in a single ink. 🥕"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main transformation: replacing per-result sharing with full conversation sharing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/genui/a2ui-playground/src/hooks/useConversation.ts`:
- Around line 459-494: The in-memory branch in useConversation.ts (inside the
!persistentRef.current block) creates meta without previewText, causing empty
previews; fix it by importing and invoking previewTextFromSharedMessages (from
conversationRepo.ts) the same way importConversation does and set
meta.previewText = previewTextFromSharedMessages(doc.messages) when building
ConversationMeta (alongside messageCount); this ensures the previewText is
populated for the in-memory path and mirrors the persistent import behavior.

In `@packages/genui/a2ui-playground/src/storage/sharedConversation.ts`:
- Around line 89-99: The runtime guard is only checking top-level fields in
isSharedConversationDoc (checking kind, v and Array.isArray(doc.messages)), so
malformed entries in doc.messages can slip through and later crash import;
update isSharedConversationDoc to validate each entry of doc.messages (for the
SharedConversationDoc message shape) by ensuring every element is a non-null
object and has the required properties and correct types (e.g., message id if
present, role/sender as string/enum, content as string or expected content
structure, timestamp as number/ISO-string if used), returning false if any
element fails, while keeping the existing checks for SHARED_CONVERSATION_KIND
and v === 1.

In `@packages/genui/a2ui-playground/src/utils/shareConversation.ts`:
- Around line 48-54: The current clearImportConversationParam function drops the
whole query string; instead, read the current URLSearchParams, delete only the
"importConv" key (use readImportConversationParam to guard), reconstruct the
query string from the remaining params and preserve window.location.hash, then
call window.history.replaceState (same usage as in the diff) with pathname +
(params.toString() ? '?' + params.toString() : '') + window.location.hash so
other query params remain intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 135cac4c-9135-420f-91ec-ecf4e80dfd7b

📥 Commits

Reviewing files that changed from the base of the PR and between baf40ba and 0c27ba2.

📒 Files selected for processing (6)
  • packages/genui/a2ui-playground/src/components/ConversationListPanel.tsx
  • packages/genui/a2ui-playground/src/hooks/useConversation.ts
  • packages/genui/a2ui-playground/src/pages/AIChatPage.tsx
  • packages/genui/a2ui-playground/src/storage/conversationRepo.ts
  • packages/genui/a2ui-playground/src/storage/sharedConversation.ts
  • packages/genui/a2ui-playground/src/utils/shareConversation.ts

Comment thread packages/genui/a2ui-playground/src/hooks/useConversation.ts
Comment thread packages/genui/a2ui-playground/src/storage/sharedConversation.ts
Comment thread packages/genui/a2ui-playground/src/utils/shareConversation.ts
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 4, 2026

Merging this PR will not alter performance

✅ 87 untouched benchmarks
⏩ 26 skipped benchmarks1


Comparing PupilTong:claude/strange-mclaren-dd0e37 (308e8a9) with main (a713484)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

- isSharedConversationDoc: validate each message entry (role + string
  content), not just the top-level shape, so a malformed shared document
  is rejected before import instead of crashing later.
- clearImportConversationParam: delete only the importConv param and
  preserve other query params (e.g. a2uiEndpoint) and the hash.
- importShared (in-memory fallback): populate previewText via
  previewTextFromSharedMessages so the conversation-list preview matches
  the persistent import path when IndexedDB is unavailable.
@PupilTong PupilTong enabled auto-merge (squash) June 4, 2026 12:25
@PupilTong PupilTong merged commit b3f0776 into lynx-family:main Jun 5, 2026
75 of 77 checks passed
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