Sessions from v0.2.8 and earlier were linked to the one before them by every rollover and New session, so production threads offered "Show the previous session" (and prompts read summaries) for sessions nothing was carried from. A link is kept only when the session opens with a message carried from that session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
21 lines
884 B
TypeScript
21 lines
884 B
TypeScript
/**
|
|
* Clears `previous_session_id` on every session that wasn't carried over:
|
|
* before v0.3.0 a rollover and New session linked each session to the
|
|
* one before it, so threads offered "Show the previous session" and
|
|
* prompts read summaries of sessions nothing was carried from. A carry
|
|
* over always opens its session with a message naming the one it came
|
|
* from (`carried_from_session_id`); a link without one is cleared.
|
|
*/
|
|
export default function clearImplicitSessionLinksSql() {
|
|
return {
|
|
sql: `UPDATE bot_sessions SET previous_session_id = NULL
|
|
WHERE previous_session_id IS NOT NULL
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM bot_messages m
|
|
WHERE m.session_id = bot_sessions.id
|
|
AND m.carried_from_session_id = bot_sessions.previous_session_id
|
|
)`,
|
|
values: [] as number[],
|
|
};
|
|
}
|