feat(background-task): show original prompt and last message in running task status

- Add prompt field to BackgroundTask to store original prompt
- Add lastMessage/lastMessageAt to TaskProgress for real-time monitoring
- Extract last assistant message during polling
- Update formatTaskStatus() to display prompt (truncated 300 chars) and
  last message (truncated 500 chars) with timestamp

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-13 13:05:12 +09:00
parent 7859f0dd2d
commit 91ae0cc67d
3 changed files with 53 additions and 11 deletions

View File

@@ -59,6 +59,7 @@ export class BackgroundManager {
parentSessionID: input.parentSessionID,
parentMessageID: input.parentMessageID,
description: input.description,
prompt: input.prompt,
agent: input.agent,
status: "running",
startedAt: new Date(),
@@ -316,7 +317,7 @@ export class BackgroundManager {
if (!messagesResult.error && messagesResult.data) {
const messages = messagesResult.data as Array<{
info?: { role?: string }
parts?: Array<{ type?: string; tool?: string; name?: string }>
parts?: Array<{ type?: string; tool?: string; name?: string; text?: string }>
}>
const assistantMsgs = messages.filter(
(m) => m.info?.role === "assistant"
@@ -324,6 +325,7 @@ export class BackgroundManager {
let toolCalls = 0
let lastTool: string | undefined
let lastMessage: string | undefined
for (const msg of assistantMsgs) {
const parts = msg.parts ?? []
@@ -332,6 +334,9 @@ export class BackgroundManager {
toolCalls++
lastTool = part.tool || part.name || "unknown"
}
if (part.type === "text" && part.text) {
lastMessage = part.text
}
}
}
@@ -341,6 +346,10 @@ export class BackgroundManager {
task.progress.toolCalls = toolCalls
task.progress.lastTool = lastTool
task.progress.lastUpdate = new Date()
if (lastMessage) {
task.progress.lastMessage = lastMessage
task.progress.lastMessageAt = new Date()
}
}
} catch (error) {
log("[background-agent] Poll error for task:", { taskId: task.id, error })