You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(bridle): "New chat" archives the transcript instead of clearing locally (v0.13.3)
Closes the loop on the New chat UX. Before: local chat cleared but
the server-side transcript was untouched, and the next reload would
restore it (token-flow) — fixed in v0.13.2 by suppressing the next
replay, but the history just kept piling up on the server with no
way to roll it over.
Now the SDK calls POST /api/agent/<id>/transcript/archive?channel=<...>
right before the reconnect. Two implementations, hub-side:
1. Bridle hub (bridle/nestjs/): new
IBridleTranscriptGateway.archive() with a default that falls back
to delete(). Integrators override to do the "right thing" for their
storage (rename to timestamped sibling, move to cold tier, etc.).
Controller endpoint POST :agentId/transcript/archive returns
{ archivedPath? }.
2. Ranch hub (ranch/api/src/slices/bridle/): the controller reads
data/sessions/bridle:<channel>.jsonl, writes the same content to
data/sessions/bridle:<channel>.<iso-ts>.archived.jsonl, then
deletes the live file. No-op when the live file is empty/missing.
Admins still have full history under the .archived. files; the
visitor gets a clean slate.
SDK side: archive call is best-effort. If the endpoint isn't there
(older hub) or the request fails, we still clear locally and reconnect
— the existing skipNextTranscript flag keeps the replay from undoing
the clear. Net effect: New chat is consistent regardless of which hub
version the embed is talking to.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: nestjs/bridle.controller.ts
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -137,4 +137,26 @@ export class BridleController {
137
137
this.logger.warn(`Transcript reset failed for ${agentId}/${channel}: ${(errasError).message}`)
138
138
}
139
139
}
140
+
141
+
@ApiOperation({
142
+
description:
143
+
'Archive the persisted chat transcript for an agent/channel. Used by the embed\'s "New chat" action when the integrator wants the visitor to see a clean slate but still keep the prior conversation for admin/audit. Default integrator binding falls back to delete; override IBridleTranscriptGateway.archive() to move-with-timestamp instead.',
144
+
operationId: 'archiveBridleTranscript',
145
+
})
146
+
@ApiQuery({name: 'channel',required: false,description: 'Session channel — defaults to "admin".'})
0 commit comments