V2 event provider adapters - #133
Conversation
|
Cursor Agent can help with this pull request. Just |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| const delta = | ||
| firstNonEmptyString( | ||
| event.textDelta, | ||
| payload?.delta, | ||
| payload?.text, | ||
| payload?.outputDelta, | ||
| payload?.summaryTextDelta, | ||
| payload?.textDelta, | ||
| ) ?? ""; |
There was a problem hiding this comment.
🟡 Medium Layers/CodexAdapter.ts:856
Using firstNonEmptyString here trims the delta text, corrupting indentation and whitespace. Consider using asString instead to preserve the raw content.
- const delta =
- firstNonEmptyString(
- event.textDelta,
- payload?.delta,
- payload?.text,
- payload?.outputDelta,
- payload?.summaryTextDelta,
- payload?.textDelta,
- ) ?? "";
+ const delta =
+ asString(event.textDelta) ??
+ asString(payload?.delta) ??
+ asString(payload?.text) ??
+ asString(payload?.outputDelta) ??
+ asString(payload?.summaryTextDelta) ??
+ asString(payload?.textDelta) ??
+ "";🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/server/src/provider/Layers/CodexAdapter.ts around lines 856-864:
Using `firstNonEmptyString` here trims the delta text, corrupting indentation and whitespace. Consider using `asString` instead to preserve the raw content.
Evidence trail:
CodexAdapter.ts lines 111-120: `firstNonEmptyString` function definition shows it returns `value.trim()`. CodexAdapter.ts lines 95-97: `asString` function returns raw string without trimming. CodexAdapter.ts lines 850-865: Context shows `firstNonEmptyString` is used for delta events including `item/commandExecution/outputDelta` and `item/fileChange/outputDelta` where whitespace preservation is critical.
7a9b3d3 to
ac45b82
Compare
Second upstream sync on this branch: pingdotgg/t3code main at 2c7267a ("stop the reaper from silently killing live background subagents", pingdotgg#5677) into the DevGame fork. 19 conflicted paths, resolved under the standing doctrine (upstream structure wins; fork features re-expressed inside it; the fork's deliberate deletions stand). Highlights taken from upstream: background-subagent reaper + settling fixes (pingdotgg#5677/pingdotgg#5568), sidebar v2 promoted to THE sidebar (pingdotgg#5672 -- SidebarV2.tsx renamed Sidebar.tsx, old sidebar now LegacySidebar.tsx behind Settings -> Legacy features), plans fold into chat (pingdotgg#5558, plan sidebar deleted), agents observability panel (pingdotgg#5219), MCP tool-result payload slimming (pingdotgg#5482), thread pagination (pingdotgg#5493), per-device provider settings (pingdotgg#4479), theme library + configurable fonts (pingdotgg#5103), thread pinning (pingdotgg#5312/pingdotgg#5581), reconnect-warning grace (pingdotgg#5670), mobile 1.0.2. Notable resolution rulings: - Right panel collapses to agents-only: upstream retired "plan", the fork had already moved preview/terminal/diff/files to the dock. ChatView's right-panel plumbing reduced accordingly; persistence shim now ALLOWLISTS the surviving kind, tolerates corrupt entries, and prunes records it empties (three tests updated to the pruned contract). - Migration id space: fork ids 36/37 (spaces) stay where deployed DevGame databases recorded them; upstream's three arrivals take 38/39/40 with files renamed to match. Crossover hazard from stock-T3 data dirs is documented at the manifest and tracked with the storage-isolation task. - useThreadSidebarComponent re-pointed at Sidebar/LegacySidebar via useLegacySidebarEnabled (forceV1 gone -- /settings* mounts SettingsSidebarNav, no thread sidebar). The pingdotgg#111 aria-label derivation ported into the renamed Sidebar.tsx. - Locale-fragile upstream snooze tests (pingdotgg#4438 asserts en-US "PM") made locale-agnostic; ThemeSettings copy re-branded to DevGame; upstream's text-secondary-label token applied in the fork's MessageImageGrid. Verification: typecheck exit 0 across every package (incl. server + desktop run separately); suites green -- server 2197, web 2400, scripts 227, contracts 228. Four-lens Opus merge-gate review over the resolution: 31 findings, 29 fixed in this commit, 2 filed as follow-up tasks (pingdotgg#133 right-panel chooser UX -- pre-existing; pingdotgg#134 migration ledger guard). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Implement v2 canonical event emission for Claude, Codex, and Cursor provider adapters to standardize event structure and enable the new Cursor agent.
Note
Add Cursor ACP provider adapter and adopt v2 canonical runtime events across server adapters and ingestion
Introduce a new
cursoradapter wired intoProviderAdapterRegistryLiveand server composition; migrate adapters, tests, and ingestion to v2 canonical runtime events (content.delta,item.*,request.*, payload-based turn states); extend provider runtime contracts with new event types, payloads, and ID types; update stale session recovery to dropresumeThreadId; broaden test harnesses to accept generic event records.📍Where to Start
Start with the Cursor adapter implementation in
makeCursorAdapterLivein CursorAdapter.ts, then review the event mapping overhaul in CodexAdapter.ts and the contract updates in providerRuntime.ts.📊 Macroscope summarized 14865dc. 10 files reviewed, 47 issues evaluated, 1 issue filtered, 1 comment posted
🗂️ Filtered Issues
apps/server/src/orchestration/Layers/CheckpointReactor.ts — 0 comments posted, 2 evaluated, 1 filtered
turnStateFromCompletionfunction strictly validates the event status against a hardcoded list ("completed","failed","interrupted","cancelled"). If the provider runtime emits any other failure status (e.g.,"error","timeout","aborted") or uses a different casing (e.g.,"FAILED"), the function returnsundefined. Thisundefinedvalue is then passed tocheckpointStatusFromRuntime(line 340), which falls back to the default case returning"ready". Consequently, unhandled failure modes are silently converted into successful ("ready") checkpoints, potentially corrupting the orchestration state with invalid checkpoints. [ Out of scope ]