fix(orchestrator): harden Grok v2 lifecycle (#3578)
Integrate the current Grok settlement, monitor/subagent lifecycle, interrupt containment, steer visibility, and image support stack into the orchestration-v2 branch. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
0282ab8608
commit
e16d4e514b
53 files changed
+15859
-985
No files matched your search
@@ -16,6 +16,7 @@ import { useV2ItemSupport } from "../../state/v2-item-support";
|
||||
|
||||
export function ThreadActivityInspector(props: {
|
||||
readonly activity: ThreadFeedActivity;
|
||||
readonly currentThreadId: ThreadId;
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly iconColor: ColorValue;
|
||||
readonly workspaceRoot?: string | null;
|
||||
@@ -28,8 +29,8 @@ export function ThreadActivityInspector(props: {
|
||||
sourceItemId: row.sourceItemId,
|
||||
});
|
||||
const model = useMemo(
|
||||
() => buildThreadActivityInspector(props.activity, support),
|
||||
[props.activity, support],
|
||||
() => buildThreadActivityInspector(props.activity, support, props.currentThreadId),
|
||||
[props.activity, props.currentThreadId, support],
|
||||
);
|
||||
const revertCheckpoint = useAtomCommand(threadEnvironment.revertCheckpoint, {
|
||||
label: "checkpoint rollback",
|
||||
|
||||
@@ -899,7 +899,7 @@ function useMarkdownStyles(onLinkPress: (href: string) => void): MarkdownStyleSe
|
||||
|
||||
function renderFeedEntry(
|
||||
info: { item: ThreadFeedEntry; index: number },
|
||||
props: Pick<ThreadFeedProps, "environmentId" | "skills" | "workspaceRoot"> & {
|
||||
props: Pick<ThreadFeedProps, "environmentId" | "skills" | "threadId" | "workspaceRoot"> & {
|
||||
readonly copiedRowId: string | null;
|
||||
readonly expandedWorkRows: Record<string, boolean>;
|
||||
readonly terminalAssistantMessageIds: ReadonlySet<string>;
|
||||
@@ -1109,6 +1109,7 @@ function renderFeedEntry(
|
||||
<ThreadWorkLog
|
||||
activities={entry.activities}
|
||||
copiedRowId={props.copiedRowId}
|
||||
currentThreadId={props.threadId}
|
||||
environmentId={props.environmentId}
|
||||
expanded={props.expandedWorkGroups[entry.id] ?? false}
|
||||
expandedRows={props.expandedWorkRows}
|
||||
@@ -1838,6 +1839,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
(info: { item: ThreadFeedEntry; index: number }) =>
|
||||
renderFeedEntry(info, {
|
||||
environmentId: props.environmentId,
|
||||
threadId: props.threadId,
|
||||
copiedRowId,
|
||||
expandedWorkRows,
|
||||
terminalAssistantMessageIds,
|
||||
@@ -1876,6 +1878,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
onToggleWorkGroup,
|
||||
onToggleWorkRow,
|
||||
props.environmentId,
|
||||
props.threadId,
|
||||
props.threadTitle,
|
||||
props.skills,
|
||||
props.workspaceRoot,
|
||||
|
||||
@@ -130,6 +130,7 @@ function ThreadActivityThreadLink(props: {
|
||||
export function ThreadWorkLog(props: {
|
||||
readonly activities: ReadonlyArray<ThreadFeedActivity>;
|
||||
readonly copiedRowId: string | null;
|
||||
readonly currentThreadId: ThreadId;
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly expanded: boolean;
|
||||
readonly expandedRows: Readonly<Record<string, boolean>>;
|
||||
@@ -263,6 +264,7 @@ export function ThreadWorkLog(props: {
|
||||
<View className="ml-7 border-l border-neutral-300/60 pb-1.5 pl-3 pt-0.5 dark:border-white/[0.12]">
|
||||
<ThreadActivityInspector
|
||||
activity={row}
|
||||
currentThreadId={props.currentThreadId}
|
||||
environmentId={props.environmentId}
|
||||
iconColor={props.iconSubtleColor}
|
||||
workspaceRoot={props.workspaceRoot}
|
||||
|
||||
@@ -93,7 +93,7 @@ describe("buildThreadActivityInspector", () => {
|
||||
} as never,
|
||||
};
|
||||
|
||||
const model = buildThreadActivityInspector(activityFor(item), support);
|
||||
const model = buildThreadActivityInspector(activityFor(item), support, sourceThreadId);
|
||||
expect(model.fields).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ label: "Duration", value: "2.0s" },
|
||||
@@ -119,7 +119,11 @@ describe("buildThreadActivityInspector", () => {
|
||||
pattern: "resolveSession",
|
||||
results: [{ fileName: "src/session.ts", line: 42, preview: "function resolveSession()" }],
|
||||
};
|
||||
const fileModel = buildThreadActivityInspector(activityFor(fileSearch), EMPTY_V2_ITEM_SUPPORT);
|
||||
const fileModel = buildThreadActivityInspector(
|
||||
activityFor(fileSearch),
|
||||
EMPTY_V2_ITEM_SUPPORT,
|
||||
sourceThreadId,
|
||||
);
|
||||
expect(fileModel.fileLinks).toEqual([
|
||||
{
|
||||
label: "src/session.ts — function resolveSession()",
|
||||
@@ -136,7 +140,11 @@ describe("buildThreadActivityInspector", () => {
|
||||
{ title: "Schema", url: "https://effect.website/docs/schema", snippet: "Typed schemas" },
|
||||
],
|
||||
};
|
||||
const webModel = buildThreadActivityInspector(activityFor(webSearch), EMPTY_V2_ITEM_SUPPORT);
|
||||
const webModel = buildThreadActivityInspector(
|
||||
activityFor(webSearch),
|
||||
EMPTY_V2_ITEM_SUPPORT,
|
||||
sourceThreadId,
|
||||
);
|
||||
expect(webModel.webLinks).toEqual([
|
||||
{ label: "Schema", url: "https://effect.website/docs/schema" },
|
||||
]);
|
||||
@@ -156,6 +164,7 @@ describe("buildThreadActivityInspector", () => {
|
||||
const dynamicModel = buildThreadActivityInspector(
|
||||
activityFor(dynamicTool),
|
||||
EMPTY_V2_ITEM_SUPPORT,
|
||||
sourceThreadId,
|
||||
);
|
||||
expect(dynamicModel.blocks).toEqual(
|
||||
expect.arrayContaining([
|
||||
@@ -177,11 +186,15 @@ describe("buildThreadActivityInspector", () => {
|
||||
files: [{ path: "src/main.ts", kind: "modified", additions: 2, deletions: 1 }],
|
||||
};
|
||||
const checkpoint = { id: checkpointId, scopeId, status: "ready" } as never;
|
||||
const model = buildThreadActivityInspector(activityFor(item), {
|
||||
...EMPTY_V2_ITEM_SUPPORT,
|
||||
item,
|
||||
checkpoint,
|
||||
});
|
||||
const model = buildThreadActivityInspector(
|
||||
activityFor(item),
|
||||
{
|
||||
...EMPTY_V2_ITEM_SUPPORT,
|
||||
item,
|
||||
checkpoint,
|
||||
},
|
||||
sourceThreadId,
|
||||
);
|
||||
|
||||
expect(model.canRollback).toBe(true);
|
||||
expect(model.rollbackTarget).toEqual({
|
||||
@@ -189,6 +202,18 @@ describe("buildThreadActivityInspector", () => {
|
||||
checkpointId,
|
||||
scopeId,
|
||||
});
|
||||
|
||||
const inheritedModel = buildThreadActivityInspector(
|
||||
activityFor(item),
|
||||
{
|
||||
...EMPTY_V2_ITEM_SUPPORT,
|
||||
item,
|
||||
checkpoint,
|
||||
},
|
||||
ThreadId.make("child-thread"),
|
||||
);
|
||||
expect(inheritedModel.canRollback).toBe(false);
|
||||
expect(inheritedModel.rollbackTarget).toBeNull();
|
||||
});
|
||||
|
||||
it("prefers live subagent progress from supporting state", () => {
|
||||
@@ -204,16 +229,20 @@ describe("buildThreadActivityInspector", () => {
|
||||
progress: "Starting",
|
||||
result: null,
|
||||
};
|
||||
const model = buildThreadActivityInspector(activityFor(item), {
|
||||
...EMPTY_V2_ITEM_SUPPORT,
|
||||
item,
|
||||
subagent: {
|
||||
origin: "provider_native",
|
||||
status: "running",
|
||||
progress: "Reading projection tests",
|
||||
result: null,
|
||||
} as never,
|
||||
});
|
||||
const model = buildThreadActivityInspector(
|
||||
activityFor(item),
|
||||
{
|
||||
...EMPTY_V2_ITEM_SUPPORT,
|
||||
item,
|
||||
subagent: {
|
||||
origin: "provider_native",
|
||||
status: "running",
|
||||
progress: "Reading projection tests",
|
||||
result: null,
|
||||
} as never,
|
||||
},
|
||||
sourceThreadId,
|
||||
);
|
||||
|
||||
expect(model.fields).toContainEqual({
|
||||
label: "Delegated task",
|
||||
|
||||
@@ -73,6 +73,7 @@ function addBlock(
|
||||
export function buildThreadActivityInspector(
|
||||
activity: ThreadFeedActivity,
|
||||
support: V2ItemSupport,
|
||||
currentThreadId: ThreadId,
|
||||
): ThreadActivityInspectorModel {
|
||||
const row = activity.projectedItem;
|
||||
const item = row.item;
|
||||
@@ -279,7 +280,10 @@ export function buildThreadActivityInspector(
|
||||
break;
|
||||
}
|
||||
|
||||
const checkpoint = item.type === "checkpoint" ? support.checkpoint : null;
|
||||
const checkpoint =
|
||||
item.type === "checkpoint" && row.sourceThreadId === currentThreadId
|
||||
? support.checkpoint
|
||||
: null;
|
||||
return {
|
||||
fields,
|
||||
blocks,
|
||||
|
||||
Reference in new issue
Block a user