fix: resolve session deletion hierarchy corruption, auto-title protocol errors, and test suite failures#199
Open
AyushDubey23 wants to merge 1 commit into
Open
fix: resolve session deletion hierarchy corruption, auto-title protocol errors, and test suite failures#199AyushDubey23 wants to merge 1 commit into
AyushDubey23 wants to merge 1 commit into
Conversation
…ol errors, and test runner loading
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
Fixes three critical bugs affecting session management reliability, auto-titling stability, and test suite execution.
Changes
1. Session Deletion Hierarchy Corruption (
app/api/sessions/[id]/route.ts)When deleting a parent session, child sessions should be re-parented to the grandparent. This failed silently on Windows because
parentSessionheader paths were compared with raw string equality — mismatched slash directions (\vs/) and drive letter casing caused the lookup to miss every child, leaving them with dangling parent pointers and corrupting the sidebar session tree.Fix: Normalize paths with
normalizeSlashes()and use case-insensitive comparison before rewriting child headers.2. Auto-Title Generation LLM Protocol Error (
lib/session-title.ts)When a session ended mid-tool-call (e.g. interrupted bash execution),
generateSessionTitle()passed the raw message history — including assistant messages with unfulfilledtoolCallblocks — directly to the title-generation model. This violated the LLM turn protocol (tool calls must be followed by tool results before a user message), causing400 Bad Requesterrors from every major provider.Fix: Added
sanitizeTitleMessages()to strip incomplete tool call blocks from assistant messages before forwarding to the title agent.3. Unit Test Suite Module Loading Failures (
lib/*.test.mjs)52 out of 89 unit tests failed with
ERR_UNKNOWN_FILE_EXTENSIONbecause test files used nativeimport("./*.ts")which Node's ESM loader rejects for TypeScript files. Additionally, two symlink-dependent tests crashed withEPERMon non-admin Windows.Fix:
jiti.import()for TypeScript module loading (consistent with the pattern already used bysession-reader.test.mjs).EPERMgraceful handling for symlink tests on Windows (bash-output.test.mjs,file-upload.test.mjs,file-dirent.test.mjs).bash-output.test.mjs.Verification
tsc --noEmit— 0 errorsnode --test lib/*.test.mjs— 95/95 passed (100%)