Repository navigation
fix(cloud-agent-sdk): validate question entries and reset retry and cleared-transcript state - #8531
Conversation
…leared-transcript state
|
bot: Verified on the extension sidepanel built from this branch, driven by a fixture cloud-agent stream whose question payload carries a valid question, an entry that does not match the shared question shape, then a second valid question. Observed on this branch, from the live DOM at capture time:
The same stream on the base revision ended with an uncaught render error while the card mounted and an empty sidepanel body; the capture here is supplementary to those DOM assertions. |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit types the validated question entries with the shared Assumptions: Files Reviewed (1 file)
Previous Review Summary (commit 1875dcd)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 1875dcd)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the Assumptions:
Files Reviewed (5 files)
Reviewed by deepseek-flash-latest · Input: 35.5K · Output: 4.7K · Cached: 465.8K Review guidance: REVIEW.md from base branch |

Evidence
Evidence: demonstrated — five regression tests fail on
mainand pass on the branch; the package suite runs 1751 tests green; and the extension sidepanel built from this branch replayed a fixture cloud-agent stream carrying one question entry that does not match the shared shape, wheremainlogged an uncaught render error and ended with an empty panel, while the branch rendered the question that precedes that entry and its Answer action submitted.Change
packages/cloud-agent-sdk/src/schemas.ts,normalizer.ts:question.askedentries are validated against the sharedQuestionInfoshape and the normalized event publishes the parsed list instead of castingunknown[]. Answers are positional (answerQuestion(requestId, answers: string[][])), so the list keeps its valid prefix and stops at the first entry that fails the shape; an entry that fails in first position makes the payload carry no questions, which is the same result as the existing non-array fallback, so the pending request still resolves and the card reports the interrupted state. An explicitly empty list stays empty.session-manager.tsclearFailedMessage: the service result is honoured. When the service reports that the pruned entry held the terminal error and has undone it, the mirrored error state is cleared, matching the durable-seed path in the same file.session-manager.tsclearTranscript: resets the omitted-item count and the initial-page accounting baseline to zero, the same reset the non-preserved branch ofclearAllAtomsperforms, so a cleared view neither reports omitted history nor caches a stale count for the next open.Verification
pnpm --filter @kilocode/cloud-agent-sdk exec jest: 35 suites, 1751 tests pass.typecheck,oxlintandoxfmt --list-differentare clean for the package.mainand pass on the branch: valid-prefix/truncation/undefined-list normalization, extra-field stripping, retry clearing the terminal error, and the cleared view resetting the omitted accounting (including the page written to the transcript cache).question.askedcarries a valid question, a malformed entry, then a second valid question. Onmainthe sidepanel recorded an uncaught render error while the card mounted and ended with an empty panel. On the branch the card renders the first question, does not offer the question after the malformed entry, and the Answer action submits. The capture is attached in a comment on this pull request.clearTranscript, and the retry residue needs a delivery-failure replay that arrives after the re-send starts, which the UI cannot force. Those are verified at the manager level with the real manager, jotai store, page-application and cache-write paths; the service-state result contract is covered by its own suite.main.Proxy answers
The owner's proxy gave these answers in the owner's place.
Answer: Truncate at the first malformed entry.
Confidence: 0.60. Precedent: executive decisions under the "is this reasonable?" rule. Truncating keeps answers aligned by position; dropping only the bad entries would silently pair an answer with the wrong CLI question.
Answer: Keep the event with the question list undefined.
Confidence: 0.65. Precedent: the same "is this reasonable?" rule. This matches the existing handling of a non-array payload, so the pending request still resolves and the card shows as interrupted.