Skip to content

refactor(app): use current session messages - #42766

Merged
Hona merged 3 commits into
anomalyco:v2from
Hona:current-session-model
Aug 18, 2026
Merged

Hona merged 3 commits into
anomalyco:v2from
Hona:current-session-model

Conversation

@Hona

@Hona Hona commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Not required for this refactor.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The shared client data layer now owns the V2 session transcript for both TUI and Desktop. This change removes Desktop's remaining full-transcript conversion into legacy Message and Part stores.

The timeline derives current message and content references directly from shared SessionMessageInfo[], renders shell messages as native rows, and converts only visible content at the existing DOM renderer boundary. Prompt display metadata, comment restoration, undo/redo prompt reconstruction, and current context views use the current message schema.

It also deletes the unused App sync overlay, dead context metric helpers, and unreachable diff-summary rows.

How did you verify your code works?

  • bun typecheck --force in packages/app
  • bun typecheck in packages/session-ui
  • bun typecheck:e2e in packages/app
  • bun run test:unit in packages/app: 551 passed
  • bun run test:browser in packages/app: 44 passed
  • bun test in packages/session-ui: 87 passed
  • Performance unit checks: 42 passed
  • App E2E suite: 96 passed, then the corrected retry lifecycle file passed 5/5

The local workspace pre-push hook also reached unrelated Node node:sqlite and Buffer type errors in packages/core and packages/cli; clean CI is running the workspace checks.

Screenshots / recordings

No visual design change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@Hona
Hona requested a review from Brendonovich as a code owner August 15, 2026 12:34
Copilot AI lite review requested due to automatic review settings August 15, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the desktop session timeline to use the current V2 SessionMessageInfo[] stream as the single source of truth, resolving legacy Message/Part transcript data at the render boundary (similar to the TUI) and adapting E2E fixtures accordingly.

Changes:

  • Remove legacy Message/Part normalization and store only SessionMessageInfo[], presenting legacy-compatible rows/parts only at render time.
  • Add native handling for shell messages as first-class timeline rows and update timeline row construction/grouping to operate on current assistant content.
  • Update prompt restore/fork/revert flows to derive prompt text, attachments, and comments from SessionMessageUser + metadata.

Reviewed changes

Copilot reviewed 58 out of 58 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/session-ui/src/context/data.tsx Makes legacy message/part stores optional to support app-side refactor away from legacy transcript state.
packages/session-ui/src/components/message-part.tsx Adds SessionShellMessage renderer and registers a shell tool renderer for session shell messages.
packages/app/src/utils/session-message.ts Replaces legacy normalization with “present*” helpers that project current protocol messages into DOM renderer structures.
packages/app/src/utils/session-message.test.ts Updates unit tests to validate presentation helpers instead of legacy normalization output.
packages/app/src/utils/prompt.ts Switches prompt restore to operate on SessionMessageUser (files/agents/metadata) and exposes comment extraction.
packages/app/src/utils/prompt.test.ts Updates prompt restore tests to cover attachments, optimistic data URLs, and review comments.
packages/app/src/utils/diffs.ts Removes legacy message summary normalization helper, keeping only diff normalization.
packages/app/src/utils/diffs.test.ts Removes tests for deleted legacy message summary normalization.
packages/app/src/utils/comment-note.ts Adds readPromptPresentation helper to read displayText + comment metadata from message metadata.
packages/app/src/types.ts Removes legacy transcript/message/part type system from app-level types.
packages/app/src/pages/session/use-session-hash-scroll.ts Updates hash-scroll helpers to work with SessionMessageUser instead of legacy UserMessage.
packages/app/src/pages/session/use-session-commands.tsx Updates revert/stage flows to restore prompts from SessionMessageUser and rehydrate comment context.
packages/app/src/pages/session/timeline/timeline-row.ts Adds Shell timeline row type and keying for shell rows.
packages/app/src/pages/session/timeline/rows.ts Rebuilds timeline row construction around current messages/content refs; adds content grouping and message-comment extraction from metadata.
packages/app/src/pages/session/timeline/rows-current.test.ts Rewrites timeline row tests to directly use current session messages (including shell + assistant-only cases).
packages/app/src/pages/session/timeline/projection.ts Removes legacy message/parts projection inputs; adds user-context projection (agent/model) derived from current stream/metadata.
packages/app/src/pages/session/timeline/model.ts Updates “timeline ready” logic to consider user or shell roots in current messages.
packages/app/src/pages/session/timeline/model.test.ts Updates model tests for current message shapes and revert boundary behavior.
packages/app/src/pages/session/timeline/message-timeline.tsx Switches timeline rendering to resolve current content at render time; integrates shell row rendering and new “current-message” adapters.
packages/app/src/pages/session/timeline/current-message.tsx New adapter components bridging current protocol messages/content into existing session-ui DOM renderers.
packages/app/src/pages/session/timeline/controller.tsx Removes legacy parts plumbing; derives task descriptions from current assistant tool content.
packages/app/src/pages/session/timeline/controller-projection.ts Adds visibleTimelineMessages to hide queued inbox items and apply revert boundary to current messages.
packages/app/src/pages/session/timeline/controller-projection.test.ts New tests covering queued-input hiding and revert-boundary filtering for current messages.
packages/app/src/pages/session/session-model-helpers.ts Narrows session restore payload to only the fields needed (sessionID/agent/model).
packages/app/src/pages/session/session-model-helpers.test.ts Updates tests for the narrowed session restore payload shape.
packages/app/src/pages/session/session-domain.ts Updates helpers to select/trim SessionMessageUser from current messages and apply revert boundary.
packages/app/src/pages/session/session-controller.ts Updates session controller to store current session messages/user messages instead of legacy transcript messages.
packages/app/src/pages/session/session-controller.test.ts Updates controller invariant tests for current message shapes.
packages/app/src/pages/session/composer/session-composer-state.ts Switches composer computations to read from serverSync.session.data.message (current messages).
packages/app/src/pages/session.tsx Removes turn-diff mode; updates session model sync + draft restoration to use current user messages + metadata.
packages/app/src/pages/directory-layout.tsx Passes a session-ui-focused subset of sync data to DataProvider to match new optional legacy fields.
packages/app/src/context/server-session.ts Removes legacy part/message projection store; uses current messages only and updates pending inbox projection metadata.
packages/app/src/context/server-session-v2-reducer.ts Ensures session.text.ended updates include state from the event.
packages/app/src/context/prompt-state.ts Inlines FilePartSource types locally after removing legacy app transcript types.
packages/app/src/context/global-sync/types.ts Updates global sync state types to store current messages and includes pending/input collections.
packages/app/src/context/global-sync/session-cache.ts Updates session cache eviction/cleanup for current message arrays (removes part caches).
packages/app/src/context/global-sync/session-cache.test.ts Updates cache tests for the new current-message-only cache shape.
packages/app/src/context/global-sync/event-reducer.ts Removes reducers for legacy message/part events and associated cleanup logic.
packages/app/src/context/global-sync/event-reducer.test.ts Removes tests that exercised legacy message/part reducers and part-only cleanup.
packages/app/src/context/global-sync/child-store.ts Updates child store initialization to include pending/input instead of legacy part stores.
packages/app/src/context/directory-sync.ts Updates synced session field set to include pending/input and remove legacy part-related fields.
packages/app/src/components/session/session-context-tab.tsx Updates raw message view and context breakdown computation to operate on current messages (no parts), removes system-prompt rendering.
packages/app/src/components/session/session-context-metrics.ts Updates context metrics to read provider/model/tokens from current assistant messages.
packages/app/src/components/session/session-context-metrics.test.ts Updates tests for current assistant/user message shapes.
packages/app/src/components/session/session-context-breakdown.ts Updates token breakdown estimation to use current message content instead of legacy parts.
packages/app/src/components/session/session-context-breakdown.test.ts Updates tests for breakdown estimation against current message shapes.
packages/app/src/components/prompt-input/submit.ts Adds metadata (displayText/comments/agent/model) to followup draft sends for prompt restoration parity.
packages/app/src/components/prompt-input/submit.test.ts Updates submit tests to assert metadata is included in the message send payload.
packages/app/src/components/prompt-input.tsx Updates “has history” logic to check SessionMessageInfo.type === "user" rather than legacy role.
packages/app/src/components/dialog-fork.tsx Restores fork prompt state from SessionMessageUser (including comment context) instead of legacy parts.
packages/app/e2e/regression/session-timeline-transport.spec.ts Updates transport regression tests to the new “current event adaptation” + content-id mapping and acknowledgement counts.
packages/app/e2e/regression/session-timeline-reducer-projection.spec.ts Updates selectors to new part/content IDs for current messages.
packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts Updates selectors to use adapted current content IDs in lifecycle regression tests.
packages/app/e2e/regression/session-timeline-history-root.spec.ts Replaces legacy “message.updated” test event with current session.step.* event payloads.
packages/app/e2e/regression/session-timeline-context-resize.spec.ts Updates test events from legacy part updates to current tool success events.
packages/app/e2e/regression/session-timeline-collapse-state.spec.ts Updates collapse-state regression tests to stream current text events and use current content IDs.
packages/app/e2e/performance/timeline-stability/fixture.ts Adapts legacy timeline events into current session events, adds content-id mapping helpers, and updates transport harness APIs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/app/src/utils/prompt.ts Outdated
Comment thread packages/app/src/utils/comment-note.ts
Comment thread packages/app/src/pages/session/timeline/rows.ts Outdated
@Hona
Hona force-pushed the current-session-model branch from bdb6c62 to 438de4a Compare August 18, 2026 01:49
@Hona
Hona merged commit a888ba4 into anomalyco:v2 Aug 18, 2026
3 checks passed
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 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.

2 participants