Skip to content

feat(web): wire compaction tab to the real assistant route#32230

Merged
dvargasfuertes merged 1 commit into
mainfrom
apollo/compaction-trail-wire-up
May 27, 2026
Merged

feat(web): wire compaction tab to the real assistant route#32230
dvargasfuertes merged 1 commit into
mainfrom
apollo/compaction-trail-wire-up

Conversation

@vellum-apollo-bot
Copy link
Copy Markdown
Contributor

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.ts hardcodes MOCK_EVENTS at Date.parse("2026-05-26T15:32:11Z" / "T15:54:38Z" / "T16:18:02Z") and slices the first N based on a hash of the callId. 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.ts resolves the floor to the most recent non-compactionAgent call 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 — new fetchCompactionTrail(assistantId, conversationId, callId, signal). Hand-rolled because the route isn't in the generated SDK yet; mirrors fetchConversationMessages and archiveConversation (path params via SDK options, no trailing slash on the action segment).
  • compaction-trail-fetch.test.ts — five tests, spying on client.get per the messages.test.ts precedent. 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 81cc6bf4 conversation that surfaced the original investigation:

Selected call Prev real call Compactions in window
post-comp#1 (22:19:20) 22:18:05 1
post-comp#2 (22:20:38) 22:19:20 1
post-comp#3 (22:28:49) 22:26:54 1
post-#4,#5 (22:31:34) 22:28:49 2
post-comp#6 (22:34:05) 22:33:03 1

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

  • Doesn't surface the silently-dropped-vs-actually-applied signal — that's still a separate workstream item (the visualization that distinguishes the two devastating bugs from the original investigation).
  • Doesn't add durationMsllm_request_logs doesn't carry it; the route ships null and the UI renders "Unavailable". That gap stays visible until we decide whether to extend the column or stand up a compaction_logs table.

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 typecheck clean
  • bun run lint clean

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 dvargasfuertes merged commit 8520c2b into main May 27, 2026
7 checks passed
@dvargasfuertes dvargasfuertes deleted the apollo/compaction-trail-wire-up branch May 27, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant