← Back to PRs

#4567: Webchat: canonicalize main session key for /new (fix #4446)

by selfboot open 2026-01-30 10:06 View on GitHub →
Fixes Web UI `/new` not starting a fresh session (#4446). Root cause: webchat often sends `SessionKey` as the `main` alias, but server-side session init didn’t canonicalize it to the real main session key. This caused resets to write to the alias while history reads from the canonical key, so the UI appeared unchanged. ## Changes - Canonicalize explicit `SessionKey` to the real main session key during session init - Propagate the canonical key into the template context to keep all paths consistent - Add a test to cover explicit `main` alias canonicalization <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes Web UI `/new` not starting a fresh session by canonicalizing the “main” session alias during session initialization. In `src/auto-reply/reply/session.ts`, the resolved session key is passed through `canonicalizeMainSessionAlias(...)`, and the canonical `SessionKey` is also propagated into the template context so subsequent code paths consistently read/write the same store key. A Vitest regression test was added in `src/auto-reply/reply/session.test.ts` to assert that an explicit `SessionKey: "main"` is canonicalized to the configured main session key (including agent scoping). <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with minimal risk; changes are narrowly scoped to session-key normalization and are covered by a regression test. - The core change (canonicalizing the main session alias) follows an existing utility used elsewhere in the codebase and is applied immediately after `resolveSessionKey`, minimizing behavioral surface area. The additional `SessionKey` propagation into the template context aligns the in-memory/session-store key with what templates/commands see. Only minor test-harness concerns remain (environment assumptions around pnpm in CI/local), but no clear functional regression is apparent from the code changes. - src/auto-reply/reply/session.test.ts (test environment assumptions) <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs