Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 62b556e

Browse files
committed
docs: refine 6c to MVP scope, expand open questions for discussion
1 parent ace099a commit 62b556e

1 file changed

Lines changed: 95 additions & 12 deletions

File tree

docs/architecture/phase-6-background-task-visibility.md

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,21 @@ interface BackgroundTaskViewState {
199199
5. If task is completed → opens BackgroundTaskReplayView
200200
6. If task is active → opens BackgroundTaskLiveView (Phase 6c)
201201

202-
### 6c. Real-time Progress Streaming
202+
### 6c. Real-time Progress Streaming (Minimal Viable Version)
203+
204+
> **Design principle:** Keep Phase 6c tightly scoped to avoid expanding the phase. Ship the simplest useful version first; richer detail can be added incrementally in later phases.
205+
206+
#### MVP Scope
207+
208+
The minimal viable version streams only:
209+
- **Tool name + status** (started / completed / errored) -- not full parameters or output
210+
- **Last N updates** (rolling window of ~20 items) -- older entries are discarded client-side
211+
- **Status changes** (running, paused, completed, errored)
212+
213+
What is explicitly **out of scope** for the MVP:
214+
- Full tool call parameters or output payloads
215+
- Assistant text streaming
216+
- Persistent storage of streamed updates (replay from disk covers completed tasks)
203217

204218
#### New Message Types
205219

@@ -212,12 +226,16 @@ interface BackgroundTaskProgress {
212226
}
213227

214228
interface BackgroundTaskUpdate {
215-
kind: "tool_call" | "tool_result" | "assistant_text" | "status_change" | "error"
229+
kind: "tool_call" | "tool_result" | "status_change" | "error"
216230
timestamp: number
217-
data: any // Typed per kind
231+
toolName?: string // e.g. "read_file", "execute_command"
232+
status?: string // e.g. "started", "completed", "errored"
233+
errorMessage?: string // Only for kind === "error"
218234
}
219235
```
220236

237+
Note: `assistant_text` is excluded from the MVP. The update interface uses typed optional fields instead of `data: any` to keep the contract narrow and safe.
238+
221239
#### Task.ts Changes
222240

223241
Add a method that emits progress regardless of whether the task is "current":
@@ -239,25 +257,29 @@ private emitBackgroundProgress(update: BackgroundTaskUpdate) {
239257
}
240258
```
241259

260+
The hook points in Task.ts should be minimal -- emit at tool call start and tool call end only. Avoid adding hooks inside the LLM streaming loop for the MVP.
261+
242262
#### Throttling Strategy
243263

244-
- Batch updates in 200ms windows
245-
- Cap at 10 updates per batch per task
246-
- Drop older updates if buffer exceeds threshold
247-
- Priority: status_change > error > tool_result > tool_call > assistant_text
264+
- Batch updates in 500ms windows (conservative default; can be tuned down later)
265+
- Cap at 5 updates per batch per task
266+
- Drop older updates if buffer exceeds threshold (keep last N = 20)
267+
- Priority ordering: status_change > error > tool_result > tool_call
248268

249269
#### Webview: BackgroundTaskLiveView
250270

251271
```
252272
BackgroundTaskLiveView
253273
├── Props: { taskId: string }
254-
├── State: updates (BackgroundTaskUpdate[]), status
274+
├── State: updates (BackgroundTaskUpdate[], capped at last 20), status
255275
├── Subscribes to backgroundTaskProgress messages filtered by taskId
256-
├── Renders: streaming list of tool calls and results
276+
├── Renders: compact list of recent tool calls with status icons
257277
├── Auto-scrolls to latest update
258278
└── Shows task status badge (running, paused, completed, errored)
259279
```
260280

281+
The live view intentionally shows a compact summary, not a full chat transcript. Users who want full detail can wait for the task to complete and use the replay view (6a).
282+
261283
## 7. Testing Strategy
262284

263285
| Area | Test Type | Key Scenarios |
@@ -270,8 +292,69 @@ BackgroundTaskLiveView
270292

271293
## 8. Open Questions
272294

273-
1. **Should the background task list be a sidebar panel or a tab?** A sidebar panel (like the existing Phase 5 panel) keeps the foreground task visible. A tab replaces the view entirely but is simpler.
295+
The following questions need alignment before implementation begins. They are grouped by area and ordered by impact.
296+
297+
### UI Layout
298+
299+
1. **Should the background task list be a sidebar panel or a tab?**
300+
301+
| Option | Pros | Cons |
302+
|--------|------|------|
303+
| **Sidebar panel** (like Phase 5 panel) | Foreground task stays visible; quick glance at background status without context-switching | More complex layout; may feel cramped in narrow viewports |
304+
| **Full tab** (`tab === "bgTask"`) | Simpler implementation; full width for task details | Replaces the current view entirely; user loses sight of foreground task |
305+
| **Hybrid** (collapsible sidebar that can expand to full view) | Best of both worlds | Highest implementation effort |
306+
307+
**Recommendation:** Start with a full tab for simplicity. If user feedback indicates they need to monitor background tasks while interacting with the foreground task, add a sidebar mode in a follow-up.
308+
309+
**Decision needed:** Which option should we ship first?
310+
311+
2. **Where does the "background tasks" entry point live?**
312+
313+
Options:
314+
- A new icon in the existing tab bar (alongside chat, history, settings)
315+
- A badge/button on the status area of the chat view
316+
- An entry in the history view with a filter for background tasks
317+
318+
**Decision needed:** Which placement feels most discoverable without adding clutter?
319+
320+
3. **Should the replay view share the ChatView component or be a separate component?**
321+
322+
Reusing `ChatView` with a read-only prop reduces duplication but may introduce coupling. A dedicated `BackgroundTaskReplayView` is more isolated but duplicates rendering logic.
323+
324+
**Recommendation:** Create a thin wrapper around `ChatRow` components rather than reusing the full `ChatView`. This avoids inheriting input controls, scroll management, and approval button logic that don't apply.
325+
326+
### Progress Streaming Granularity
327+
328+
4. **What level of detail should the MVP stream?**
329+
330+
| Level | What's shown | Bandwidth / perf cost |
331+
|-------|-------------|----------------------|
332+
| **Minimal** (recommended for MVP) | Tool name + status (started/completed/errored) | Very low |
333+
| **Medium** | Tool name + truncated first argument (e.g., file path) | Low |
334+
| **Full** | Complete tool parameters + output | High -- requires careful truncation |
335+
336+
**Recommendation:** Ship with minimal level. The tool name and status provide enough signal to know "what the background task is doing right now" without performance risk. Medium level can be added as a fast follow if users want more context.
337+
338+
**Decision needed:** Is the minimal level sufficient, or should we target medium from the start?
339+
340+
5. **Should streaming updates be opt-in?**
341+
342+
If multiple background tasks are running, streaming all of them simultaneously could be noisy. Options:
343+
- Stream all tasks by default, throttle aggressively
344+
- Only stream updates for the currently-viewed background task
345+
- Let users toggle streaming per task
346+
347+
**Recommendation:** Only stream updates for the currently-viewed background task (the one selected in the background task list). This keeps the implementation simple and avoids unnecessary message traffic.
348+
349+
**Decision needed:** Confirm this approach or choose an alternative.
350+
351+
6. **How should errors in background tasks be surfaced?**
352+
353+
When a background task hits an error, the user may not notice if they're focused on the foreground task. Options:
354+
- Badge/notification on the background tasks tab icon
355+
- Toast notification
356+
- Both
274357

275-
2. **Message size limits for replay:** Completed tasks can have thousands of messages. Should we paginate or lazy-load? Initial recommendation: load all at once (same as current ChatView behavior), optimize if performance becomes an issue.
358+
**Recommendation:** Badge on the tab icon (low disruption). Toast notifications can be added later if users miss errors.
276359

277-
3. **Progress streaming granularity:** Should we stream every tool call parameter, or just tool names + status? Start with names + status, add detail incrementally.
360+
**Decision needed:** Is a badge sufficient, or do we need more prominent notification?

0 commit comments

Comments
 (0)