Repository navigation
fix(antigravity): Show background command summaries and live output #40687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |
| commandProgramName, | ||
| } from "@t3tools/client-runtime/work-log/command-label"; | ||
| import { | ||
| commandCustomTitle, | ||
| commandlessCommandLabel, | ||
| contextCompactionLabel, | ||
| liveThoughtLine, | ||
|
|
@@ -301,6 +302,8 @@ export function workEntryRowLabel( | |
| : resolve(msg("Thought")); | ||
| const presentation = resolveWorkEntryToolPresentation(entry, undefined, resolve); | ||
| if (presentation) return presentation.displayName; | ||
| const customCommandTitle = commandCustomTitle(entry); | ||
| if (customCommandTitle) return compactWorkEntryText(customCommandTitle); | ||
| if (entry.command?.trim()) return compactWorkEntryText(commandDisplayText(entry.command)); | ||
| const commandless = commandlessCommandLabel( | ||
| entry, | ||
|
|
@@ -957,6 +960,8 @@ function singleToolCallLabel( | |
| : compactWorkEntryText(activity.workEntry.detail ?? "") || resolve(msg("Thought")); | ||
| const presentation = resolveWorkEntryToolPresentation(activity.workEntry, "completed", resolve); | ||
| if (presentation) return presentation.displayName; | ||
| const customCommandTitle = commandCustomTitle(activity.workEntry); | ||
| if (customCommandTitle) return compactWorkEntryText(customCommandTitle); | ||
| const command = activity.workEntry.command?.trim(); | ||
| return command ? truncate(command, WORK_LOG_LABEL_MAX_LENGTH) : activity.summary; | ||
| } | ||
|
|
@@ -1822,6 +1827,31 @@ export function deriveThreadFeedPresentation( | |
| for (const entryId of fold.hiddenEntryIds) collapsedEntryIds.add(entryId); | ||
| } | ||
| } | ||
| const tailIsActiveActivityGroup = | ||
| activeTailGroup?.type === "activity-group" && activeTailGroup.runId === activeRunId; | ||
| const trailingRunningCommands: ThreadFeedActivity[] = []; | ||
| const trailingRunningCommandIds = new Set<string>(); | ||
| if ( | ||
| !zen && | ||
| isWorking && | ||
| latestRun?.turnEnded !== true && | ||
| !tailIsActiveActivityGroup && | ||
| (activeRunId !== null || runlessWorkActive) | ||
| ) { | ||
| for (const entry of sourceFeed) { | ||
| if (entry.type !== "activity-group" || collapsedEntryIds.has(entry.id)) continue; | ||
| for (const activity of entry.activities) { | ||
| if ( | ||
| activity.projectedItem.item.type === "command_execution" && | ||
| activity.lifecycleStatus === "inProgress" && | ||
| activity.runId === activeRunId | ||
| ) { | ||
| trailingRunningCommands.push(activity); | ||
| trailingRunningCommandIds.add(activity.id); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // The working run's fold row shows its live timer where "Worked for" lands once it settles. | ||
| // Zen never folds, so it keeps only the Thinking row. | ||
| // Runless work folds under its prompt's key once it settles, so the live row takes that key. | ||
|
|
@@ -1930,9 +1960,24 @@ export function deriveThreadFeedPresentation( | |
| result.push(...rows); | ||
| continue; | ||
| } | ||
| const presentationEntry = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove relocated commands before the failed-run branch. If an active run contains a failed error item, Apply the removal before both presentation branches. Keep each running command in exactly one location.
|
||
| trailingRunningCommandIds.size > 0 && entry.type === "activity-group" | ||
| ? { | ||
| ...entry, | ||
| activities: entry.activities.filter( | ||
| (activity) => !trailingRunningCommandIds.has(activity.id), | ||
| ), | ||
| } | ||
| : entry; | ||
| if ( | ||
| presentationEntry.type === "activity-group" && | ||
| presentationEntry.activities.length === 0 | ||
| ) { | ||
| continue; | ||
| } | ||
| appendPresentedFeedEntry( | ||
| result, | ||
| entry, | ||
| presentationEntry, | ||
| expandedWorkGroupIds, | ||
| activeRunId, | ||
| isWorking, | ||
|
|
@@ -1943,6 +1988,25 @@ export function deriveThreadFeedPresentation( | |
| } | ||
| } | ||
| if (liveFold !== null && !liveFoldPlaced) result.push(liveFold); | ||
| if (trailingRunningCommands.length > 0) { | ||
| const anchor = trailingRunningCommands[0]!; | ||
| appendPresentedFeedEntry( | ||
| result, | ||
| { | ||
| type: "activity-group", | ||
| id: anchor.id, | ||
| createdAt: anchor.createdAt, | ||
| runId: activeRunId, | ||
| activities: trailingRunningCommands, | ||
| }, | ||
| expandedWorkGroupIds, | ||
| activeRunId, | ||
| isWorking, | ||
| true, | ||
| resolve, | ||
| locale, | ||
| ); | ||
| } | ||
| if ( | ||
| isWorking && | ||
| activeWorkStartedAt !== null && | ||
|
|
@@ -2412,6 +2476,8 @@ function liveToolActivitySummary( | |
| resolve, | ||
| ); | ||
| if (presentation) return presentation.displayName; | ||
| const customCommandTitle = commandCustomTitle(activity.workEntry); | ||
| if (customCommandTitle) return compactWorkEntryText(customCommandTitle); | ||
| const command = activity.workEntry.command?.trim(); | ||
| if (command) { | ||
| const program = commandProgramName(command); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost"; | |
| import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; | ||
| import { makeAcpAdapterV2 } from "@t3tools/provider-acp/server/adapter"; | ||
| import { makeAntigravityAcpRuntime } from "../../provider/acp/AntigravityAcpSupport.ts"; | ||
| import { commandStep } from "../../provider/acp/AntigravityChildWork.testkit.ts"; | ||
| import { normalizeAntigravitySessionUpdate } from "../../provider/acp/AntigravityProtocol.ts"; | ||
| import { ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE } from "../../provider/antigravityAuthSupport.ts"; | ||
| import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; | ||
|
|
@@ -1672,6 +1673,84 @@ describe("AntigravityAdapterV2 work after the prompt ends", () => { | |
| }).pipe(Effect.provide(layerSession)), | ||
| ); | ||
|
|
||
| it.live( | ||
| "tails background task-<idx>.log into command_output.delta and hydrates toolSummary from SQLite", | ||
| () => | ||
| Effect.gen(function* () { | ||
| const fileSystem = yield* FileSystem.FileSystem; | ||
| const path = yield* Path.Path; | ||
| const NodeSqlite = yield* Effect.promise(() => import("node:sqlite")); | ||
| const profile = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-ag-cmd-tail-" }); | ||
| const acpDir = path.join(profile, "antigravity-acp"); | ||
| const conversationsDir = path.join(acpDir, "conversations"); | ||
| const tasksDir = path.join(acpDir, "brain", "mock-session-1", ".system_generated", "tasks"); | ||
| yield* fileSystem.makeDirectory(conversationsDir, { recursive: true }); | ||
| yield* fileSystem.makeDirectory(tasksDir, { recursive: true }); | ||
| const db = new NodeSqlite.DatabaseSync(path.join(conversationsDir, "mock-session-1.db")); | ||
| db.exec( | ||
| "CREATE TABLE steps (idx integer PRIMARY KEY, step_type integer NOT NULL DEFAULT 0, step_format integer NOT NULL DEFAULT 0, step_payload blob)", | ||
| ); | ||
| db.prepare("INSERT INTO steps (idx, step_type, step_payload) VALUES (?, ?, ?)").run( | ||
| 17, | ||
| 132, | ||
| commandStep({ | ||
| callId: "call_bg_capture", | ||
| commandLine: "python3 capture.py", | ||
| toolSummary: "Capture 60 frames if sky is clean", | ||
| }), | ||
| ); | ||
| db.close(); | ||
| const logFile = path.join(tasksDir, "task-17.log"); | ||
| yield* fileSystem.writeFileString(logFile, "sky median 412 ADU\n"); | ||
|
|
||
| const cmd = { | ||
| toolCallId: "call_bg_capture", | ||
| kind: "execute", | ||
| title: "Run command", | ||
| rawInput: { CommandLine: "python3 capture.py", WaitMsBeforeAsync: 5000 }, | ||
| } as const; | ||
| const { send, startTurn, until, throughPromptSettled } = | ||
| yield* openSessionWithRunningCommand({}, undefined, undefined, { | ||
| profileDirectory: profile, | ||
| initialToolCalls: [{ sessionUpdate: "tool_call", ...cmd, status: "in_progress" }], | ||
| }); | ||
| yield* startTurn(1, false); | ||
| yield* throughPromptSettled; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the events that
Retain the returned events. Before waiting on the queue, check them for the title and output milestones. Alternatively, collect all three milestones through one consumer that starts before the prompt.
|
||
|
|
||
| const sawTitle = yield* until( | ||
| (event) => | ||
| event.type === "turn_item.updated" && | ||
| event.turnItem.type === "command_execution" && | ||
| event.turnItem.title === "Capture 60 frames if sky is clean", | ||
| ); | ||
| assert.isTrue(sawTitle.length > 0); | ||
| const sawChunk = yield* until( | ||
| (event) => | ||
| event.type === "command_output.delta" && event.chunk.includes("sky median 412 ADU"), | ||
| ); | ||
| assert.isTrue(sawChunk.length > 0); | ||
|
|
||
| yield* fileSystem.writeFileString(logFile, "sky median 412 ADU\n60 frames captured\n"); | ||
| yield* send({ | ||
| sessionUpdate: "tool_call_update", | ||
| ...cmd, | ||
| status: "completed", | ||
| rawOutput: { combinedOutput: "sky median 412 ADU\n60 frames captured\n", exitCode: 0 }, | ||
| }); | ||
| const settled = yield* until( | ||
| (event) => | ||
| event.type === "turn_item.updated" && | ||
| event.turnItem.type === "command_execution" && | ||
| event.turnItem.status === "completed", | ||
| ); | ||
| const completedEvent = settled.at(-1); | ||
| assert.equal( | ||
| completedEvent?.type === "turn_item.updated" ? completedEvent.turnItem.title : null, | ||
| "Capture 60 frames if sky is clean", | ||
| ); | ||
| }).pipe(Effect.provide(layerSession)), | ||
| ); | ||
|
|
||
| // agy 1.5.11 reads a prompt sent mid-turn as a steer: it answers the running prompt end_turn | ||
| // and goes on under the new one. session/cancel would end its running commands and subagents. | ||
| it.effect("steers a running prompt with the next one and leaves its work running", () => | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep earlier running commands pinned when another activity follows.
For
running command → interim reply → completed file search, the final search group makestailIsActiveActivityGrouptrue. This guard disables relocation. The running command stays above the reply, and the completed search occupies the trailing activity row.Collect outstanding commands even when another activity group occupies the tail. Combine their presentation without duplicating a command already at the tail.