Skip to content

fix: resolve session deletion hierarchy corruption, auto-title protocol errors, and test suite failures#199

Open
AyushDubey23 wants to merge 1 commit into
agegr:mainfrom
AyushDubey23:main
Open

fix: resolve session deletion hierarchy corruption, auto-title protocol errors, and test suite failures#199
AyushDubey23 wants to merge 1 commit into
agegr:mainfrom
AyushDubey23:main

Conversation

@AyushDubey23

Copy link
Copy Markdown

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 parentSession header 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 unfulfilled toolCall blocks — directly to the title-generation model. This violated the LLM turn protocol (tool calls must be followed by tool results before a user message), causing 400 Bad Request errors 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_EXTENSION because test files used native import("./*.ts") which Node's ESM loader rejects for TypeScript files. Additionally, two symlink-dependent tests crashed with EPERM on non-admin Windows.

Fix:

  • Updated all 15 affected test files to use jiti.import() for TypeScript module loading (consistent with the pattern already used by session-reader.test.mjs).
  • Added EPERM graceful handling for symlink tests on Windows (bash-output.test.mjs, file-upload.test.mjs, file-dirent.test.mjs).
  • Fixed platform-dependent path assertion in bash-output.test.mjs.

Verification

  • TypeScript: tsc --noEmit — 0 errors
  • Unit Tests: node --test lib/*.test.mjs95/95 passed (100%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant