Files
triggerdotdev--trigger.dev/apps/webapp
Eric Allam 37503a4f43 feat(sdk,playground,ai-chat): chat.agent on Sessions-as-run-manager
chat.agent now runs on top of the Session-as-run-manager primitive.
Public surface (`chat.agent({...})`, `useTriggerChatTransport`,
`chat.store` / `chat.defer` / `chat.history`, `AgentChat`) is unchanged;
the wiring underneath moves from per-run streams to the durable Session
row that owns its own runs.

Transport (TriggerChatTransport):
- Drop `getStartToken`. Replace with
  `startSession({chatId, taskId, clientData}) => {publicAccessToken}` —
  wraps a server action that calls `chat.createStartSessionAction`.
  Idempotent on `(env, externalId)`.
- `clientData` (typed via `withClientData`) is threaded through
  `startSession`'s params, so the first run's `basePayload.metadata`
  matches per-turn `metadata`. Live-updated via `setClientData` when
  the hook's `clientData` option changes.
- Drop transport-level `triggerConfig` / `triggerOptions` /
  `idleTimeoutInSeconds`. All trigger config lives server-side in the
  customer's `chat.createStartSessionAction(taskId, options)`.
- `transport.preload(chatId)` and lazy first `sendMessage` both route
  through `startSession`, deduped via the in-flight pendingStarts map.
- `ChatSession` persistable shape drops `runId`; just `{lastEventId}`.

chat.agent runtime:
- New `chat.createStartSessionAction(taskId, options?)` — server-side
  wrapper that calls `sessions.start` with `basePayload.{messages:[],
  trigger: "preload"}` defaults plus the customer's overrides. Returns
  `{sessionId, runId, publicAccessToken}`.
- `chat.requestUpgrade` calls `apiClient.endAndContinueSession` before
  emitting the `trigger:upgrade-required` chunk. Server orchestrates
  the swap; browser keeps streaming across the run handoff.

Webapp dashboard:
- Playground: `startSession` + `accessToken` both wired through the
  Remix action (idempotent server-side start path). Preload button
  now works. New session proxy routes for HEAD/GET on `/out` and POST
  on `/in/append`; old run-stream proxies deleted.
- Run inspector Agent tab: SSE proxy now uses the canonical addressing
  key (externalId if set, else friendlyId), matching what the agent
  writes via `session.out`. Fixes the case where the Agent tab read
  from a different S2 stream than the agent wrote to.

References (ai-chat):
- `chat-view` useEffect dance gone (just hydrates `initialSession`).
- `chat-app` `transport.preload(id)` routes through `startSession`.
- New `upgrade-test` agent + sidebar option for exercising
  `chat.requestUpgrade` end-to-end.
- `ChatSession` schema simplified: drop `runId` / `sessionId`, keep
  `publicAccessToken` + `lastEventId`.
- `chat-client-test` fixed for the new transport shape.
- Hello-world smoke stubs gutted to TODO placeholders — sessions
  are now task-bound, so standalone-session smokes need rewriting.
2026-05-05 11:06:25 +01:00
..
2026-01-09 11:39:36 +00:00
2025-03-08 14:53:06 +00:00
2023-01-10 16:09:42 +00:00
2022-12-06 12:28:16 +00:00
2024-10-09 12:52:52 +01:00

Trigger webapp - powered by Remix

To start, run with pnpm run dev --filter webapp

Build the docker image locally:

pnpm run docker:build:webapp
docker run -it triggerdotdev-webapp sh