Repository navigation
Conversation
Angular chat binds the active thread to the URL with injectThreadRouting: restore on load, push on change, follow navigation, and replace a thread that fails validation with the bare URL. React chat had no URL binding. useThreadRouting does the same in @threadplane/react/chat. React has no single router, so the URL binding is an adapter (read, write, subscribe); the default uses window.location and history with Angular's /<threadId> shape, a configurable basePath or query param, and reads nothing during the server render or hydration. An optional exists check replaces a missing thread with the bare URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
blove
enabled auto-merge
November 18, 2026 01:28
CodeQL flagged /\/+$/ in normalizeBase as a polynomial regular expression on uncontrolled data. A backwards loop over trailing slashes is linear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
Angular exports
injectThreadRouting(libs/chat/src/lib/routing/thread-routing.ts): it seeds the active thread from the URL, navigates (push) when the thread changes, follows router navigation, and on a failedvalidatenavigates to the bare path withreplaceUrl: true. React chat had no URL binding at all.This adds an opt-in
useThreadRouting(options)hook to@threadplane/react/chatwith the same behavior:{ threadId, setThreadId }; the URL is the source of truth (no local storage).setThreadIdpushes a history entry (no write when the thread is already active); back and forward (popstate) are followed.exists(id): boolean | Promise<boolean>; onfalse, the URL is replaced with the bare URL. Each id is checked once until another is selected (Angular memoizes the same way), a late answer for a thread that is no longer in the URL is ignored, and a rejected check keeps the thread.adapter: { read, write(id, 'push' | 'replace'), subscribe }for React Router or Next.js. The default adapter useswindow.location/historywith Angular's URL shape (/<threadId>), a configurablebasePath(/chat/<threadId>) or aparam(?thread=<threadId>), and keeps the query and hash (Angular preserves query params).useSyncExternalStorewith anullserver snapshot, so neither the server render nor hydration reads the URL; the default adapter reads nothing withoutwindow.ThreadSidebarandThreadDirectoryare not on main, so there is no directory-based default; the docs wireThreadListactiveThreadId/onSelectto the hook. A directory-basedexistscan be layered on once those land.Also:
useThreadRoutingadded to the verify-packages allowlist and its spec fixture, disposition rows appended for the new exports and source file, and a "Keep the active thread in the URL" section in the React thread-routing guide.Verification
libs/react/src/chat/thread-routing.spec.tsx(16 tests) failed before the implementation (no export), passes after. Mutation checks: making the server snapshot read the URL, dropping the late-answer guard, writing selections with replace, and accepting nested path segments each fail a test.NX_DAEMON=false npx nx run-many -t test lint type-tests -p react --skip-nx-cache: passed (1541 tests).node --test scripts/react-parity/verify-packages.spec.mjs: 103 passed.node scripts/react-parity/inventory.mjs --check --drift warn: valid (baseline drift is informational only).npx vitest runin apps/website: 1965 passed, 4 failed, none related to this change.docs-example-code.spec.ts(5s timeout under load) andFooter.spec.tsxpass alone with--testTimeout=60000;api/ingest/route.spec.tscannot resolveposthog-nodeandgenerate-api-docs.spec.tsrejects the symlinked shared node_modules, both local environment issues in this worktree.🤖 Generated with Claude Code