feat(web): wire compaction tab to the real assistant route#32230
Merged
Conversation
Replaces the development mock with a real call to
`GET /v1/assistants/:id/conversations/:cid/compaction?callId=…` (handler:
`assistant/src/runtime/routes/conversation-compaction-routes.ts`).
The assistant scopes the trail server-side to compactions that ran in
the open window between the previous non-`compactionAgent` LLM call
and the selected one. Picking a different call in the rail still
produces a different trail; the difference is that the trail now
reflects the call's actual context-build window instead of the mock's
hardcoded `2026-05-26T15:32:11Z`-and-friends timestamps.
- `compaction-trail-fetch.ts` — `fetchCompactionTrail(assistantId,
conversationId, callId, signal)`. Hand-rolled because the route
isn't in the generated SDK yet; mirrors `fetchConversationMessages`
and `archiveConversation`.
- `compaction-trail-fetch.test.ts` — spies on `client.get` per
`messages.test.ts` precedent. Pins URL pattern, path/query params,
signal forwarding, HTTP-error → `CompactionTrailRequestError`,
malformed-body branch.
- `compaction-trail-api.ts` — swap mock import → real fetcher; the
React Query shape is unchanged so the tab doesn't need updates.
- `compaction-tab.tsx` doc comment updated to describe the route
semantic instead of the mock.
- `compaction-trail-mock.{ts,test.ts}` deleted.
dvargasfuertes
approved these changes
May 27, 2026
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.
Why
The Compaction tab was showing compactions outside the window between the previous LLM call and the selected one — three events frozen at 11:32 / 11:54 / 12:18 PM, regardless of which call you clicked.
The screenshot Vargas surfaced this morning is the mock:
compaction-trail-mock.tshardcodesMOCK_EVENTSatDate.parse("2026-05-26T15:32:11Z" / "T15:54:38Z" / "T16:18:02Z")and slices the first N based on a hash of thecallId. There's no relationship between those timestamps and the rail.The real route was already shipped and already implements the right semantic —
assistant/src/runtime/routes/conversation-compaction-routes.tsresolves the floor to the most recent non-compactionAgentcall before the selected one and returns compactions strictly in(floor, selectedCall.createdAt). The frontend just never got wired to it.What
compaction-trail-fetch.ts— newfetchCompactionTrail(assistantId, conversationId, callId, signal). Hand-rolled because the route isn't in the generated SDK yet; mirrorsfetchConversationMessagesandarchiveConversation(path params via SDK options, no trailing slash on the action segment).compaction-trail-fetch.test.ts— five tests, spying onclient.getper themessages.test.tsprecedent. Pins URL pattern, path/query params, abort-signal forwarding, HTTP-error →CompactionTrailRequestError, malformed-body branch.compaction-trail-api.ts— swap the mock import for the real fetcher. Query shape unchanged, so the Compaction tab itself needs no edits.compaction-tab.tsx— doc comment updated to describe the route semantic instead of the mock.compaction-trail-mock.{ts,test.ts}deleted (the mock's own doc-comment said to do this when the real route shipped).Verification
Simulated the real route against the actual
81cc6bf4conversation that surfaced the original investigation:Tight prev-call → selected-call windows, never more than 2 (and that's the back-to-back emergency-then-retry pair). Each call in the rail now shows only the compactions that built its own context.
What this PR does not do
durationMs—llm_request_logsdoesn't carry it; the route shipsnulland the UI renders "Unavailable". That gap stays visible until we decide whether to extend the column or stand up acompaction_logstable.Test plan
bun test src/domains/chat/inspector/compaction-trail-fetch.test.ts(5 / 5 pass)bun test src/domains/chat/inspector/(47 / 47 pass)bun run typecheckcleanbun run lintclean