feat(opencode): show actual model per turn #6551
ClosedKarmCraft(GitHub profile, opens in a new tab)wants to merge 9 commits into
main fromrefs/pull/6551/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/OpenCodeAdapter.test.ts line 1137OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1071,0 +1117,21 @@1117+1118+ const eventsFiber = yield* adapter.streamEvents.pipe(1119+ Stream.filter((event) => event.threadId === threadId),1120+ Stream.take(4),1121+ Stream.runCollect,1122+ Effect.forkChild,1123+ );1124+1125+ yield* adapter.startSession({1126+ provider: ProviderDriverKind.make("opencode"),1127+ threadId,1128+ runtimeMode: "full-access",1129+ });1130+ yield* adapter.sendTurn({1131+ threadId,1132+ input: "identify the model",1133+ modelSelection: createModelSelection(ProviderInstanceId.make("opencode"), "kedvai/auto"),1134+ });1135+ releaseEvents?.();1136+1137+ const events = Array.from(yield* Fiber.join(eventsFiber).pipe(Effect.timeout("1 second")));apps/web/src/components/chat/MessagesTimeline.tsx lines 1126 to 1133OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1127,12 +1125,9 @@1127- {!row.message.streaming && (1128- <Tooltip>1129- <TooltipTrigger1130- render={<p className="text-muted-foreground text-xs tabular-nums" />}1131- >1132- {formatShortTimestamp(row.message.updatedAt, ctx.timestampFormat)}1133- </TooltipTrigger>1134- <TooltipPopup>1135- {formatChatTimestampTooltip(row.message.updatedAt, ctx.timestampFormat)}1136- </TooltipPopup>1137- </Tooltip>1138- )}1125+ <div className="mt-1.5 flex items-center gap-2 text-xs tabular-nums">1126+ {row.message.actualModel ? (1127+ <p1128+ data-assistant-actual-model1129+ className="max-w-[22rem] truncate text-muted-foreground"1130+ title={`Actual model: ${row.message.actualModel}`}1131+ >1132+ Model: {row.message.actualModel}1133+ </p>
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 994Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -893,3 +902,7 @@893902 context.partById.set(part.id, part);894903 const messageRole = messageRoleForPart(context, part);895904905+ const actualModel = actualModelFromPart(part);906+ if (messageRole === "assistant" && context.activeTurnId && actualModel) {907+ context.activeActualModel = actualModel;908+ }
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1103OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1057,4 +1097,7 @@10571097 }1058109810591099 if (event.properties.status.type === "idle" && turnId) {1100+ const actualModel = context.activeActualModel;10601101 context.activeTurnId = undefined;1102+ context.activeActualModel = undefined;1103+ context.completedTurnWithoutModel = actualModelapps/server/src/provider/Layers/OpenCodeAdapter.ts line 915OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -893,3 +910,6 @@893910 context.partById.set(part.id, part);894911 const messageRole = messageRoleForPart(context, part);895912913+ const actualModel = actualModelFromPart(part);914+ const partTurnId = context.assistantTurnIdByMessageId.get(part.messageID);915+ if (messageRole === "assistant" && partTurnId && actualModel) {
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 932OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -895 +912,21 @@895912913+ const actualModel = actualModelFromPart(part);914+ const partTurnId = context.assistantTurnIdByMessageId.get(part.messageID);915+ if (messageRole === "assistant" && partTurnId && actualModel) {916+ if (context.activeTurnId === partTurnId) {917+ context.activeActualModel = actualModel;918+ } else if (context.completedTurnWithoutModel?.turnId === partTurnId) {919+ const completedTurn = context.completedTurnWithoutModel;920+ context.completedTurnWithoutModel = undefined;921+ yield* emit({922+ ...(yield* buildEventBase({923+ threadId: context.session.threadId,924+ turnId: completedTurn.turnId,925+ raw: event,926+ })),927+ type: "turn.completed",928+ payload: {929+ state: completedTurn.state,930+ actualModel,931+ },932+ });
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1122OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1057,4 +1113,10 @@10571113 }1058111410591115 if (event.properties.status.type === "idle" && turnId) {1116+ const actualModel = context.activeActualModel;10601117 context.activeTurnId = undefined;1118+ context.activeActualModel = undefined;1119+ if (actualModel) {1120+ context.completedTurnsWithoutModel.delete(turnId);1121+ } else {1122+ context.completedTurnsWithoutModel.set(turnId, "completed");
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 926Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -828,7 +872,11 @@828872 case "message.updated": {829873 context.messageRoleById.set(event.properties.info.id, event.properties.info.role);830874 if (event.properties.info.role === "assistant") {875+ if (turnId) {876+ context.turnIdByMessageId.set(event.properties.info.id, turnId);877+ }831878 for (const part of context.partById.values()) {832879 if (part.messageID !== event.properties.info.id) {833880 continue;834881 }882+ yield* captureActualModel(context, part, event);
- apps/server/src/provider/Layers/OpenCodeAdapter.ts lines 893 to 893OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -828,3 +889,5 @@828889 case "message.updated": {829890 context.messageRoleById.set(event.properties.info.id, event.properties.info.role);830891 if (event.properties.info.role === "assistant") {892+ if (turnId) {893+ context.turnIdByMessageId.set(event.properties.info.id, turnId);
- apps/web/src/components/chat/MessagesTimeline.tsx lines 1134 to 1134OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1124,9 +1124,11 @@11241124 onOpenTurnDiff={ctx.onOpenTurnDiff}11251125 />11261126 {row.showAssistantMeta ? (1127- <div className="mt-1.5 flex items-center gap-2 text-xs tabular-nums opacity-0 transition-opacity duration-200 focus-within:opacity-100 group-hover/assistant:opacity-100">1128- <AssistantCopyButton row={row} />1129- {!row.message.streaming && (1127+ <div className="mt-1.5 flex items-center gap-2 text-xs tabular-nums">1128+ {row.message.actualModel ? (11301129 <Tooltip>11311130 <TooltipTrigger1132- render={<p className="text-muted-foreground text-xs tabular-nums" />}1131+ render={1132+ <p1133+ data-assistant-actual-model1134+ className="max-w-[22rem] truncate text-muted-foreground"
juliusmarminge closed this
Sign in to join this conversation.




📝 Walkthrough
Walkthrough#
OpenCode now reports the model used for each assistant turn. The value flows through orchestration contracts, persistence, projections, client state, and web/mobile message metadata.
Changes#
Actual model attribution
packages/contracts/src/providerRuntime.ts,packages/contracts/src/orchestration.ts,apps/server/src/provider/Layers/OpenCodeAdapter.ts,apps/server/src/provider/Layers/OpenCodeAdapter.test.tsapps/server/src/persistence/Migrations/*,apps/server/src/persistence/Services/ProjectionThreadMessages.ts,apps/server/src/persistence/Layers/ProjectionThreadMessages.ts,apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.tsactual_model. Repository and snapshot mappings validate, store, preserve, select, and exposeactualModel.apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts,apps/server/src/orchestration/decider.ts,apps/server/src/orchestration/projector.ts,apps/server/src/orchestration/Layers/ProjectionPipeline.ts,apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tspackages/client-runtime/src/state/threadReducer.ts,apps/web/src/components/chat/MessagesTimeline.tsx,apps/web/src/components/chat/MessagesTimeline.test.tsx,apps/mobile/src/features/threads/ThreadFeed.tsxactualModel. Web and mobile metadata displays the model when available.Estimated code review effort: 3 (Moderate) | ~25 minutes
Mergeability Score: 🔵 Low · up to
ba49dThis PR adds optional per-turn model attribution across ingestion, persistence, and web/mobile display. It is mergeable with owner awareness: a timing edge case could omit the model label, long identifiers may be inaccessible when truncated, desktop display should be confirmed, and the fixed test timeout could cause flaky CI.
Sequence Diagram(s)#
Suggested reviewers:
juliusmarminge,t3dotgg🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#6536by capturing OpenCode model metadata, preserving it through the pipeline, and displaying it for assistant messages.✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share