injectThreadRouting

Bind an app-owned activeThreadId signal to the URL — restore on load, stamp on change, validate-or-redirect, with a bare URL meaning "no thread" (welcome). URL is the source of truth; nothing is written to localStorage. Must be called in an injection context.

import { injectThreadRouting } from '@threadplane/angular/chat';

Declaration · overload 1

export declare function injectThreadRouting(config: ThreadRoutingConfig): void;

Parameters

config · required
ThreadRoutingConfig

Returns

void

Examples

export const ACTIVE_THREAD = signal<string | null>(null);
// app.config.ts, with a LangGraph backend:
// provideAgent({
//   threadId: ACTIVE_THREAD,
//   onThreadId: (id) => ACTIVE_THREAD.set(id),
//   createSession: (context) => createSession({ assistantId, apiUrl, ...context }),
// }),
// provideThreadDirectory({
//   createDirectory: (context) => createLangGraphThreadDirectory({ apiUrl, ...context }),
// }),

// In a component, with `injectThreadDirectory` from `@threadplane/angular`:
const threads = injectThreadDirectory();
injectThreadRouting({
  threadId: ACTIVE_THREAD,
  // `getThread` resolves null for a thread that does not exist.
  validate: (id) => threads.getThread(id).then(Boolean),
});