Skip to content

Issue 01: Adapter Foundation For Sample Migration #90

Description

@yaohaowei0914

Source file: docs/issues/2026-04-22-opentui-example-migration-01-adapter-foundation.md

Labels: ui, frontend, opentui, foundation
Priority: P1
Depends on: none

Goal

Create the compatibility layer that allows the active OpenTUI frontend to absorb sample-tree behavior without importing upstream runtime assumptions directly.

Why First

The sample tree assumes a different runtime, richer store shape, and different rendering contracts. Without an adapter layer, every imported slice will couple the maintained frontend back to the old architecture.

Scope

  • Add a Lite-facing adapter/view-model layer under ui/src/
  • Normalize current protocol/store shapes into component-friendly types
  • Pre-create target directories for staged migration

Suggested Paths

  • ui/src/view-model/
  • ui/src/adapters/
  • ui/src/components/messages/
  • ui/src/components/permissions/
  • ui/src/components/mcp/
  • ui/src/components/teams/
  • ui/src/components/shell/
  • ui/src/components/PromptInput/
  • ui/src/components/StructuredDiff/

Inputs

Active frontend:

  • ui/src/ipc/protocol.ts
  • ui/src/store/app-state.ts
  • ui/src/store/message-model.ts
  • ui/src/components/App.tsx

Reference corpus:

  • ui/examples/upstream-patterns/src/components/**

Tasks

  1. Define a normalized message/tool/status view model for the maintained frontend.
  2. Add mapping utilities from current FrontendContentBlock, ConversationMessage, and RawMessage shapes.
  3. Add adapter helpers for:
    • assistant text
    • thinking
    • tool use / tool result
    • image blocks
    • system messages
    • permission requests
  4. Pre-create destination component directories even if most files are still placeholders.
  5. Add tests for the adapter layer where current store logic is already covered by unit tests.

Acceptance Criteria

  • No new active code depends on ui/examples/upstream-patterns/ imports.
  • The adapter layer compiles under the current OpenTUI build.
  • Later issues can consume normalized types without touching raw protocol parsing.
  • bun run build succeeds in ui/.

Out Of Scope

  • replacing the current message UI
  • replacing the composer
  • introducing the sample-tree runtime

Verification

  • bun run build in ui/
  • adapter-focused tests if new mapper logic is introduced

Epic

Parent epic: #89

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions