Skip to content

Issue 01: Adapter foundation for sample migration - #97

Merged
Crsei merged 1 commit into
Crsei:tuifrom
yaohaowei0914:claude/jovial-wozniak-815554
Apr 22, 2026
Merged

Issue 01: Adapter foundation for sample migration#97
Crsei merged 1 commit into
Crsei:tuifrom
yaohaowei0914:claude/jovial-wozniak-815554

Conversation

@yaohaowei0914

@yaohaowei0914 yaohaowei0914 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds the Lite adapter + view-model layer so later OpenTUI sample migration slices consume normalized types instead of raw FrontendContentBlock / ConversationMessage / PermissionRequest shapes.
  • Pre-creates staged component directories (messages/, permissions/, mcp/, teams/, shell/, PromptInput/, StructuredDiff/) with placeholder index.ts barrels, per the paths listed in Issue 01: Adapter Foundation For Sample Migration #90.
  • Covers the adapter surface with 40 new tests.

Base: tui — built on top of 2255908 Retire the old ink-terminal frontend path.

New files

  • ui/src/view-model/types.tsMessageViewModel union (user text/image, assistant message segmented on tool_use, tool use/result, system info), PermissionRequestViewModel, ImageRef, ToolStatus, PermissionCategory
  • ui/src/adapters/content-blocks.tsFrontendContentBlock[] / ToolResultContent / ToolResultContentInfo[] normalization
  • ui/src/adapters/messages.tsmapRawMessageToViewModels / mapConversationMessageToViewModels with assistant-segment splitting, user image extraction, embedded tool_result handling, redacted-thinking flagging
  • ui/src/adapters/permissions.ts — option hotkey parsing and tool categorization (bash / file_edit / file_write / web_fetch / tool_generic)
  • ui/src/adapters/tool-status.ts, ui/src/adapters/tool-input.ts — status classification and input description helpers that mirror the existing store heuristics

Constraints honored (per #89)

  • 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/.

Test plan

  • bun run build in ui/ — bundled 70 modules, 2.74 MB entry
  • bun test src/adapters — 40 pass / 0 fail (5 files, 99 assertions)
  • bun test full suite — 82 pass / 1 unrelated env failure (missing Rust binary for IPC integration test)
  • grep confirms no active import ... from '.../upstream-patterns/...' in ui/src

Closes #90.

🤖 Generated with Claude Code

Adds the view-model and adapter layer that later OpenTUI sample
migration slices will consume, so components can render from
normalized types instead of parsing raw `FrontendContentBlock`,
`ConversationMessage`, or `PermissionRequest` shapes directly.

- `ui/src/view-model/` — message/tool/status/permission types
- `ui/src/adapters/` — content-block, message, permission,
  tool-status, and tool-input normalization helpers
- Placeholder `index.ts` barrels for the staged migration targets:
  messages, permissions, mcp, teams, shell, PromptInput,
  StructuredDiff
- 40 new tests covering the adapter surface

Closes Crsei#90.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yaohaowei0914
yaohaowei0914 changed the base branch from rust-lite to tui April 22, 2026 11:10
@Crsei
Crsei merged commit dc3638b into Crsei:tui Apr 22, 2026
1 of 4 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.

Issue 01: Adapter Foundation For Sample Migration

2 participants