fix: improve compaction diagnostics and embedded plugin surfaces - #1278
Merged
Merged
Conversation
Add bounded session diagnostics for failed context compaction requests so provider errors can be investigated without writing prompt content, tool schemas, or credentials. Keep the diagnostics outside the transcript and classify them with the session logs.
Embedded plugin documents are composited inside the host work panel, so their default document edge must not add an unconfigurable frame. Reset only the embedded root and body surface chrome while leaving detached plugin windows unchanged.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Compaction diagnostics currently have stale state, incomplete fields, and incorrect retry correlation.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Adds privacy-conscious compaction diagnostics and removes default framing from embedded plugin panels.
Changes:
- Routes compaction failure/request-shape diagnostics to session logs.
- Resets embedded plugin document chrome.
- Adds targeted tests and updates runtime/UX specifications.
| File | Description |
|---|---|
packages/agent-runtime/src/sidecar.ts |
Relays runtime diagnostics. |
packages/agent-runtime/src/runtime.ts |
Produces compaction diagnostics. |
packages/agent-runtime/src/compaction-request.ts |
Observes outgoing request shape. |
packages/agent-runtime/src/compaction-request.test.ts |
Tests shape observation. |
packages/agent-runtime/src/compaction-diagnostics.ts |
Builds bounded shape metadata. |
packages/agent-runtime/src/compaction-diagnostics.test.ts |
Tests metadata sanitization. |
apps/desktop/electron/main/runtime/sidecar.ts |
Writes diagnostics to session logs. |
apps/desktop/electron/preload/plugin-panel.ts |
Removes embedded document framing. |
apps/desktop/test/plugin-work-panel-views.test.mjs |
Checks embedded surface resets. |
docs/spec/03-runtime/09-logging-and-observability.md |
Documents compaction records. |
docs/spec/04-ux/08-component-spec.md |
Documents frameless plugin views. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+11
to
+12
| const MAX_FIELDS = 32; | ||
| const FIELD_RE = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/; |
Comment on lines
+6457
to
+6461
| private emitCompactionFailureDiagnostic( | ||
| requestId: string, | ||
| reason: CompactionFailureReason, | ||
| tokensBefore: number | undefined, | ||
| error: unknown, |
| } satisfies AgentEventEnvelope); | ||
| } | ||
| } | ||
| if (method === "agent.diagnostic") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Validation
pnpm check:pr-basepnpm --filter @pi-desktop/agent-runtime typecheckpnpm --filter @pi-desktop/agent-runtime exec vitest run src/compaction-diagnostics.test.ts src/compaction-request.test.ts src/runtime.test.ts --testNamePattern='compaction|Compaction'node --test test/plugin-work-panel-views.test.mjs test/plugins-page-style.test.mjs(fromapps/desktop)Fixes #1164
Fixes #1168