Skip to content

feat(bridge): conversation list + resume protocol for the extension - #1070

Merged
edenreich merged 1 commit into
mainfrom
feat/bridge-conversation-list-resume
Aug 16, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/bridge-conversation-list-resume

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

CLI half of opentask#146. Adds bridge protocol frames so the opentask sidepanel can list the user's stored conversations and resume a chosen one, mirroring the CLI 1:1 (the same conversations infer persists and resumes from under .infer/conversations).

Closes #1068.

New wire frames (protocol v4)

Direction Frame Purpose
ext → CLI {"type":"list_conversations"} request the stored list
CLI → ext {"type":"conversations","conversations":[{"id","title","updated_at","message_count"}]} response, newest-first
ext → CLI {"type":"resume_conversation","id":"<id>"} switch active conversation to id
CLI → ext {"type":"conversation_snapshot","messages":[...]} existing frame, now the resume response

After a resume, the running chat pump streams live chat_event frames into the now-active conversation.

Implementation notes

  • resume reuses the repo's existing LoadConversation(ctx, id) + sendSnapshot — both already on the domain.ConversationRepository interface, so no interface change.
  • list type-asserts b.repo to a small local conversationLister interface (the ListSavedConversations method lives only on the concrete *PersistentConversationRepository). This keeps internal/domain/interfaces.go untouched (no counterfeiter regen) and lets the in-memory fallback repo cleanly return an empty list.
  • The implicit auto-backfill-on-connect (sendSnapshot in adopt) is removed — the panel now lists/resumes explicitly. Existing tests all inject a nil repo where sendSnapshot was already a no-op, so blast radius is nil.
  • protocol_version bumped 3 → 4 in the browser_hello_ack.
  • Concurrency: PersistentConversationRepository guards its own state, so calling these from the per-connection readLoop goroutine is race-safe (verified with -race).

Docs

docs/browser-extension-protocol.md — reworked the Conversation sync section to document the new frames in the existing house style; bumped the handshake protocol_version to 4. Public-docs follow-up filed: inference-gateway/docs#555.

Tests

Three new tests in extension_bridge_test.go against a real persistent repo backed by in-memory storage:

  • TestExtensionBridgeListConversations — list returns both seeded conversations with id/title/updated_at/message_count.
  • TestExtensionBridgeResumeConversation — resume ships the target conversation's snapshot and switches the active conversation.
  • TestExtensionBridgeNoAutoSnapshotOnConnect — regression guard: no unsolicited snapshot after connect.

go test -race ./internal/services -run TestExtensionBridge and full task test both green; task precommit:run clean.

Deliberately deferred

  • Pagination params on list_conversations (hardcoded limit 50, matching the TUI selector).
  • Refreshing the terminal TUI when the panel resumes (resume swaps the shared active conversation but emits no TUI-refresh event).
  • An error frame back to the panel on a failed resume (bad id) — currently logged, no snapshot.

Add list_conversations -> conversations and resume_conversation ->
conversation_snapshot frames so the opentask panel can list the user's
stored conversations and resume a chosen one, backed by the same store
infer resumes from (.infer/conversations).

resume reuses the repo's LoadConversation + sendSnapshot; list type-asserts
to a narrow conversationLister interface so the domain interface is untouched
and the in-memory fallback repo yields an empty list. The implicit
auto-backfill-on-connect is dropped and protocol_version bumps to 4.

Closes #1068
@edenreich
edenreich requested a review from a team as a code owner August 16, 2026 00:41
@edenreich
edenreich merged commit 8298cb2 into main Aug 16, 2026
1 check passed
@edenreich
edenreich deleted the feat/bridge-conversation-list-resume branch August 16, 2026 00:42
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.173.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Bridge: conversation list + resume protocol for the extension

1 participant