feat(opencode): show native Task subagents in the Agents panel #7393
Closedinayayousfi(GitHub profile, opens in a new tab)wants to merge 10 commits into
main fromrefs/pull/7393/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.ts line 1337Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -953,0 +1148,21 @@1148+ })),1149+ type: "task.updated",1150+ payload: {1151+ taskId: task.taskId,1152+ status: "running",1153+ ...(task.description ? { description: task.description } : {}),1154+ ...linkage,1155+ },1156+ });1157+ }1158+ task.status = "running";1159+ }1160+1161+ if (1162+ !taskRemainsRunning &&1163+ (part.state.status === "completed" || part.state.status === "error")1164+ ) {1165+ const failed = part.state.status === "error";1166+ const summary = trimText(1167+ part.state.status === "error" ? part.state.error : part.state.output,1168+ );
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 263Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -231,3 +248,4 @@231248 readonly pendingQuestions: Map<string, QuestionRequest>;232249 readonly messageRoleById: Map<string, "user" | "assistant">;233250 readonly partById: Map<string, Part>;251+ readonly taskLifecycleByTaskId: Map<RuntimeTaskId, OpenCodeTaskLifecycle>;
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1309Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -953,0 +1152,21 @@1152+ previousTask1153+ ? {1154+ ...startedBase,1155+ type: "task.updated",1156+ payload: {1157+ taskId: task.taskId,1158+ status: "running",1159+ ...(task.description ? { description: task.description } : {}),1160+ ...linkage,1161+ },1162+ }1163+ : {1164+ ...startedBase,1165+ type: "task.started",1166+ payload: {1167+ taskId: task.taskId,1168+ ...(task.description ? { description: task.description } : {}),1169+ ...linkage,1170+ },1171+ },1172+ );
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1260Resolvedby inayayousfi(GitHub profile, opens in a new tab)@@ -951,3 +1130,19 @@9511130 };9521131 appendTurnItem(context, turnId, part);9531132 yield* emit(runtimeEvent);1133+1134+ const previousTaskPart =1135+ previousPart?.type === "tool" &&1136+ previousPart.tool.toLowerCase() === "task" &&1137+ previousPart.state.status !== "pending"1138+ ? previousPart1139+ : undefined;1140+ const knownTaskId =1141+ taskIdFromPart(part) ??1142+ (previousTaskPart ? taskIdFromPart(previousTaskPart) : undefined);1143+ const previousTask = knownTaskId1144+ ? context.taskLifecycleByTaskId.get(knownTaskId)1145+ : undefined;1146+ const task = taskLifecycleFromPart(part, previousTask);1147+ const taskRemainsRunning =1148+ part.state.status === "completed" && part.state.metadata["background"] === true;
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1321Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -953,0 +1180,21 @@1180+ ...startedBase,1181+ type: "task.started",1182+ payload: {1183+ taskId: task.taskId,1184+ ...(task.description ? { description: task.description } : {}),1185+ ...linkage,1186+ },1187+ },1188+ );1189+ if (!previousTask && typeof part.state.input["task_id"] === "string") {1190+ yield* emit({1191+ ...startedBase,1192+ type: "task.updated",1193+ payload: {1194+ taskId: task.taskId,1195+ status: "running",1196+ ...(task.description ? { description: task.description } : {}),1197+ ...linkage,1198+ },1199+ });1200+ }
inayayousfi(GitHub profile, opens in a new tab) changed the title
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1812Resolvedby inayayousfi(GitHub profile, opens in a new tab)@@ -1405,3 +1760,8 @@14051760 stopped: yield* Ref.make(false),14061761 sessionScope: started.sessionScope,14071762 };1763+ const subscriptionExit = yield* Effect.exit(prepareEventSubscription(context));1764+ if (Exit.isFailure(subscriptionExit)) {1765+ const cause = Cause.squash(subscriptionExit.cause);1766+ yield* stopOpenCodeContext(context).pipe(Effect.ignoreCause);1767+ return yield* toProcessError(input.threadId, cause);apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1084Resolvedby inayayousfi(GitHub profile, opens in a new tab)@@ -801,0 +1031,21 @@1031+ callId: undefined,1032+ terminal: { notification: terminal, raw: part },1033+ });1034+ }1035+ }1036+ }1037+1038+ return Array.from(latestByTaskId.values()).flatMap(1039+ (state): ReadonlyArray<OpenCodeStoredTaskTerminal> =>1040+ state.terminal1041+ ? [1042+ {1043+ notification: state.terminal.notification,1044+ raw: state.terminal.raw,1045+ eventId: EventId.make(1046+ `opencode-task-history:${context.session.threadId}:${context.openCodeSessionId}:${state.terminal.raw.id}`,1047+ ),1048+ },1049+ ]1050+ : [],1051+ );
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1027OutdatedResolvedby inayayousfi(GitHub profile, opens in a new tab)@@ -801,0 +1007,21 @@1007+ >();1008+1009+ for (const entry of messages.data ?? []) {1010+ for (const part of entry.parts) {1011+ if (entry.info.role === "assistant" && part.type === "tool") {1012+ const taskId = taskIdFromPart(part);1013+ if (taskId) {1014+ const current = latestByTaskId.get(taskId);1015+ if (current?.callId !== part.callID) {1016+ latestByTaskId.set(taskId, {1017+ callId: part.callID,1018+ task: taskLifecycleFromPart(part, undefined),1019+ terminal: undefined,1020+ });1021+ } else {1022+ current.task = taskLifecycleFromPart(part, current.task);1023+ }1024+ }1025+ }1026+1027+ const terminal = taskNotificationFromPart(part);
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 679Resolvedby inayayousfi(GitHub profile, opens in a new tab)@@ -519,0 +659,21 @@659+ part.type !== "tool" ||660+ (part.state.status !== "completed" && part.state.status !== "error")661+ ) {662+ return undefined;663+ }664+ const taskId = taskIdFromPart(part);665+ if (666+ !taskId ||667+ (part.state.status === "completed" && part.state.metadata["background"] === true)668+ ) {669+ return undefined;670+ }671+ const summary = trimText(672+ part.state.status === "error" ? part.state.error : openCodeTaskResult(part.state.output),673+ );674+ return {675+ taskId,676+ status: part.state.status === "error" ? "failed" : "completed",677+ summary,678+ };679+}
juliusmarminge closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
945202a9-e307-45bf-9f69-4ba8c2bd5cdeYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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