Skip to content

Type tool input/metadata in the domain; point the display pipeline's dependencies downward - #1013

Merged
ivanfenenko merged 2 commits into
chore/typed-events-and-neutral-ui-typesfrom
chore/typed-tool-parts-and-pipeline-seam
Nov 10, 2026
Merged

ivanfenenko merged 2 commits into
chore/typed-events-and-neutral-ui-typesfrom
chore/typed-tool-parts-and-pipeline-seam

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Layering refactor, part 2 of 2. Stacked on #1012 (base branch chore/typed-events-and-neutral-ui-types); review and merge that first. No behaviour change, no UI change.

What moved and why

  • Typed tool data (both platforms). Timeline UI read wire keys out of ToolPart.input / .metadata (per-tool chrome and step titles, background work, child session linking, the tool result sheet). New domain/message/ToolPartFields (.kt / .swift) holds per-meaning accessors with the same names on both platforms: inputPattern, inputSearchPath, inputQuery, inputUrl/inputURL, inputCommand, inputTaskBrief, inputTargetPath, inputReadPath, inputQuestions, questionAnswers, childSessionId, isBackground, fileExisted, exitCode, patchFileCount, patchFiles, filediff*, executeCallPreviews, resultFields, linkedChildSessionId, withChildSessionId, subagent*, summaryCalls, and so on. Each accessor keeps the exact read rule its surface used (for example, Android's builder reads a JSON null as "null" while the result sheet skips it; background work only accepts JSON strings), so every tool renders as before. The raw fields stay on the model: SessionCacheCodec (schemaVersion 1) and both protocols' adapters are untouched. ToolPartIdentity.isQuestion(tool) was added so UI does not pass tool.input.
  • Android pipeline/timeline seam. DisplayMessagePipeline called the UI block builder (buildOrFallback) to decide whether a message is a single text block. PresentationBlockId and the default timeline's segmentation (text runs, tool grouping, transparent parts, visibility and part-id rules) move to domain/message/pipeline (TimelineSegments). The UI builder's default path now maps those segments to blocks, and the pipeline counts text runs (TimelineSegments.hasSoleTextBlock). The chip, step-rail and activity-card builders stay in the UI. SessionChatTimelineBlocksResult stays in the UI in its own file. A new TimelineSegmentsTest checks that the pipeline rule agrees with the built blocks. DisplayMessagePipelineCharacterizationTest is unchanged and green.
  • iOS Markdown model and highlighter. The document model (NativeMarkdownDocument, block/inline/list/table/code-span/diff/diagnostic types, data only), OpenCodeRenderedMarkdownVariant, OpenCodeRenderedMarkdownDetector and OpenCodeRenderedMarkdownParser move from Components/Chat and UI/Markdown to Domain/Markdown. The SwiftUI rendering stays in Components. MessageContentPreparer.shared is now defined in DI/AppContainer.swift with Container.codeHighlighter passed to its initializer, and AppContainer passes the highlighter to DisplayMessagePipeline(codeHighlighter:) for memory-pressure trims. Domain/ no longer references Container or imports FactoryKit in those two files.

After this PR: grep -rn "^import dev.opencode.mobile.ui" android/.../domain is empty; no non-playground file under Android ui/ imports kotlinx.serialization.json; no non-playground file under iOS UI/ or Components/ references AnyCodable or AnySendable.

Checks

  • Android (JDK 17), from android/: ./gradlew :app:assembleDebug :app:compileDebugAndroidTestKotlin :app:testDebugUnitTest --continue → BUILD SUCCESSFUL; 3508 unit tests, 0 failures, 1 skipped (one new test). The first commit was also compiled on its own, and its timeline, tool-result, background-work and linker tests passed (284 tests).
  • iOS: xcodebuild build-for-testing Debug and xcodebuild build Release for generic/platform=iOS Simulator → succeeded. xcodebuild test -only-testing:"OpenCode MobileTests" on a dedicated simulator → 3474 tests in 334 suites passed.
  • gitleaks git --pre-commit --staged before each commit: no leaks.
  • No UI change.

Risks / Follow-ups

  • Android builder rules now live in TimelineSegments. Only the default path was cut; the chip, step-rail and activity-card walks still sit in the UI builder.
  • The platforms read some fields differently, and this PR keeps those differences rather than unifying them. iOS reads only JSON strings everywhere and reads line as a scalar. On iOS, summaryCallCount returns the raw count (including 0) and searchResultCount reads matches then count. Android has grepMatchCount / globFileCount and ignores an empty summary. iOS also has inputRequestedTool and inputDirectory, which Android UI has no use for.
  • iOS DisplayMessagePipeline's snapshot-source initializer (playground and tests) still does not observe memory pressure, as before. The MessageSync initializer defaults codeHighlighter to the same HighlightCoreHighlightingEngine.shared that Container.codeHighlighter is.
  • android/screenshot fails to compile on origin/main as well (pre-existing, see Type live events in the domain; move UiText and SplitPanePreferences out of the wrong layer #1012); none of the moved files are symlinked into it.
  • The iOS half of the first commit was not built on its own; the branch head was built and tested on both platforms.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

ivanfenenko and others added 2 commits November 10, 2026 00:19
Timeline UI indexed a tool part's raw input / metadata JSON by wire key
(per-tool chrome, step titles, background work, child session linking,
the tool result sheet). Add ToolPartFields in domain/message on both
platforms: per-meaning accessors (inputPattern, inputTargetPath,
childSessionId, patchFiles, executeCallPreviews, questionAnswers,
summaryCalls, resultFields, withChildSessionId, ...) that keep each
surface's existing read rule. UI consumes them; the raw fields stay on
the model, so the session cache and protocol adapters are untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Android: DisplayMessagePipeline called the UI block builder to decide
whether a message is one text block. PresentationBlockId and the default
timeline's text-run segmentation (text runs, tool grouping, visibility
and part-id rules) move to domain/message/pipeline as TimelineSegments;
the UI builder maps segments to blocks and the pipeline counts text
runs. A test checks the two agree.

iOS: the Markdown document model (NativeMarkdownDocument and its block,
inline, code-span and diff types), the variant/detector and the parser
move from Components / UI to Domain/Markdown; the SwiftUI rendering
stays in Components. The highlighter reaches DisplayMessagePipeline and
MessageContentPreparer.shared through their initializers from
AppContainer instead of the domain reading Container.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 10, 2026 08:16

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 3 passes agreed on.

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.139 · 1 pass(es) stopped early

@ivanfenenko
ivanfenenko merged commit 9a72cfc into chore/typed-events-and-neutral-ui-types Nov 10, 2026
@ivanfenenko
ivanfenenko deleted the chore/typed-tool-parts-and-pipeline-seam branch November 10, 2026 14:26
ivanfenenko added a commit that referenced this pull request Nov 10, 2026
…out of the wrong layer (#1012)

* Type live-event queries in the domain on both platforms

Feature code matched server event-name strings and read raw event
properties itself. Add typed queries on OpencodeEvent in domain/event
(worktree and branch updates, run end, reconnect, model catalog refresh,
archive change, session error and user abort, title / revert / delete /
move updates) and move the event names there. UI subscribers use the
typed form, and SessionInfo / SessionChatViewModel no longer hold an
EventDomainAdapter. The adapter keeps its query methods as delegates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move Android UiText out of the ui package

Five domain files imported UiText from ui.text. The plain type and its
lookup-based resolve move to domain.text; the Android Resources lookup
and the Compose resolve() stay in ui.text (UiTextResources.kt). The
serialization surrogates in TimelineText.kt carry explicit serial names,
so navigation keys serialize exactly as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move SplitPanePreferences beside the split-pane component

The store in domain/preferences depended on the design-system types
OpenCodeSplitPaneScreen / State / Layout on both platforms. It now lives
next to the component (Android ui/components/layout, package
ui.components; iOS Components/Layout). Storage names, keys and values
are unchanged. The screenshot module already compiles
ui/components/layout, so its symlink to the old path is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Type tool input/metadata in the domain; point the display pipeline's dependencies downward (#1013)

* Read tool input and metadata through typed domain accessors

Timeline UI indexed a tool part's raw input / metadata JSON by wire key
(per-tool chrome, step titles, background work, child session linking,
the tool result sheet). Add ToolPartFields in domain/message on both
platforms: per-meaning accessors (inputPattern, inputTargetPath,
childSessionId, patchFiles, executeCallPreviews, questionAnswers,
summaryCalls, resultFields, withChildSessionId, ...) that keep each
surface's existing read rule. UI consumes them; the raw fields stay on
the model, so the session cache and protocol adapters are untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Point the display pipeline's dependencies down into the domain

Android: DisplayMessagePipeline called the UI block builder to decide
whether a message is one text block. PresentationBlockId and the default
timeline's text-run segmentation (text runs, tool grouping, visibility
and part-id rules) move to domain/message/pipeline as TimelineSegments;
the UI builder maps segments to blocks and the pipeline counts text
runs. A test checks the two agree.

iOS: the Markdown document model (NativeMarkdownDocument and its block,
inline, code-span and diff types), the variant/detector and the parser
move from Components / UI to Domain/Markdown; the SwiftUI rendering
stays in Components. The highlighter reaches DisplayMessagePipeline and
MessageContentPreparer.shared through their initializers from
AppContainer instead of the domain reading Container.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Invalidate on background stop from the occupancy stream only

The sync coordinator invalidated on both the stopped occupancy and the
backgroundStop signal, which arrive on separate tasks. A late signal could
invalidate after a foreground catch-up started and force a second reload,
which made ProjectionReconciliationTests flaky on CI.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant