feat(statusline): expose agent ID, conversation ID, and last run ID in payload (#1249)
This commit is contained in:
@@ -1037,6 +1037,9 @@ export default function App({
|
||||
conversationIdRef.current = conversationId;
|
||||
}, [conversationId]);
|
||||
|
||||
// Track the most recent run ID from streaming (for statusline display)
|
||||
const lastRunIdRef = useRef<string | null>(null);
|
||||
|
||||
const resumeKey = useSuspend();
|
||||
|
||||
// Pending conversation switch context — consumed on first message after a switch
|
||||
@@ -2482,7 +2485,9 @@ export default function App({
|
||||
currentDirectory: process.cwd(),
|
||||
projectDirectory,
|
||||
sessionId: conversationId,
|
||||
agentId,
|
||||
agentName,
|
||||
lastRunId: lastRunIdRef.current,
|
||||
totalDurationMs: sessionStatsSnapshot.totalWallMs,
|
||||
totalApiDurationMs: sessionStatsSnapshot.totalApiMs,
|
||||
totalInputTokens: sessionStatsSnapshot.usage.promptTokens,
|
||||
@@ -4368,6 +4373,8 @@ export default function App({
|
||||
|
||||
// Update currentRunId for error reporting in catch block
|
||||
currentRunId = lastRunId ?? undefined;
|
||||
// Expose to statusline
|
||||
if (lastRunId) lastRunIdRef.current = lastRunId;
|
||||
|
||||
// Track API duration and trajectory deltas
|
||||
sessionStatsRef.current.endTurn(apiDurationMs);
|
||||
@@ -7355,7 +7362,9 @@ export default function App({
|
||||
currentDirectory: wd,
|
||||
projectDirectory,
|
||||
sessionId: conversationIdRef.current,
|
||||
agentId,
|
||||
agentName,
|
||||
lastRunId: lastRunIdRef.current,
|
||||
totalDurationMs: stats.totalWallMs,
|
||||
totalApiDurationMs: stats.totalApiMs,
|
||||
totalInputTokens: stats.usage.promptTokens,
|
||||
|
||||
@@ -9,7 +9,9 @@ export interface StatusLinePayloadBuildInput {
|
||||
currentDirectory: string;
|
||||
projectDirectory: string;
|
||||
sessionId?: string;
|
||||
agentId?: string | null;
|
||||
agentName?: string | null;
|
||||
lastRunId?: string | null;
|
||||
totalDurationMs?: number;
|
||||
totalApiDurationMs?: number;
|
||||
totalInputTokens?: number;
|
||||
@@ -38,6 +40,7 @@ export interface StatusLinePayload {
|
||||
project_dir: string;
|
||||
};
|
||||
session_id?: string;
|
||||
last_run_id: string | null;
|
||||
transcript_path: string | null;
|
||||
version: string;
|
||||
// Back-compat fields used by custom statusline scripts.
|
||||
@@ -76,6 +79,7 @@ export interface StatusLinePayload {
|
||||
mode: string | null;
|
||||
} | null;
|
||||
agent: {
|
||||
id: string | null;
|
||||
name: string | null;
|
||||
};
|
||||
permission_mode: string | null;
|
||||
@@ -137,6 +141,7 @@ export function buildStatusLinePayload(
|
||||
project_dir: input.projectDirectory,
|
||||
},
|
||||
...(input.sessionId ? { session_id: input.sessionId } : {}),
|
||||
last_run_id: input.lastRunId ?? null,
|
||||
transcript_path: null,
|
||||
version: getVersion(),
|
||||
reasoning_effort: input.reasoningEffort ?? null,
|
||||
@@ -167,6 +172,7 @@ export function buildStatusLinePayload(
|
||||
exceeds_200k_tokens: usedContextTokens > 200_000,
|
||||
vim: null,
|
||||
agent: {
|
||||
id: input.agentId ?? null,
|
||||
name: input.agentName ?? null,
|
||||
},
|
||||
permission_mode: input.permissionMode ?? null,
|
||||
|
||||
@@ -9,9 +9,11 @@ export const STATUSLINE_NATIVE_FIELDS: StatusLineFieldSpec[] = [
|
||||
{ path: "workspace.current_dir" },
|
||||
{ path: "workspace.project_dir" },
|
||||
{ path: "session_id" },
|
||||
{ path: "last_run_id" },
|
||||
{ path: "version" },
|
||||
{ path: "model.id" },
|
||||
{ path: "model.display_name" },
|
||||
{ path: "agent.id" },
|
||||
{ path: "agent.name" },
|
||||
{ path: "cost.total_duration_ms" },
|
||||
{ path: "cost.total_api_duration_ms" },
|
||||
|
||||
@@ -27,7 +27,9 @@ export interface StatusLineInputs {
|
||||
currentDirectory: string;
|
||||
projectDirectory: string;
|
||||
sessionId?: string;
|
||||
agentId?: string | null;
|
||||
agentName?: string | null;
|
||||
lastRunId?: string | null;
|
||||
totalDurationMs?: number;
|
||||
totalApiDurationMs?: number;
|
||||
totalInputTokens?: number;
|
||||
@@ -68,7 +70,9 @@ function toPayloadInput(inputs: StatusLineInputs): StatusLinePayloadBuildInput {
|
||||
currentDirectory: inputs.currentDirectory,
|
||||
projectDirectory: inputs.projectDirectory,
|
||||
sessionId: inputs.sessionId,
|
||||
agentId: inputs.agentId,
|
||||
agentName: inputs.agentName,
|
||||
lastRunId: inputs.lastRunId,
|
||||
totalDurationMs: inputs.totalDurationMs,
|
||||
totalApiDurationMs: inputs.totalApiDurationMs,
|
||||
totalInputTokens: inputs.totalInputTokens,
|
||||
|
||||
Reference in New Issue
Block a user