fix(sessions): update changed share URLs (#1184)

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-12 11:05:54 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent e50a484633
commit bb5a6fb83b
2 changed files with 31 additions and 1 deletions
@@ -0,0 +1,30 @@
import { beforeEach, describe, expect, test } from 'bun:test';
import type { Session } from '@opencode-ai/sdk/v2';
import { useGlobalSessionsStore } from './useGlobalSessionsStore';
const buildSession = (shareUrl: string): Session => ({
id: 'ses_1',
title: 'Shared session',
time: { created: 1, updated: 2 },
share: { url: shareUrl },
} as Session);
describe('useGlobalSessionsStore', () => {
beforeEach(() => {
useGlobalSessionsStore.setState({
activeSessions: [],
archivedSessions: [],
sessionsByDirectory: new Map(),
hasLoaded: false,
status: 'idle',
});
});
test('updates an existing session when the share URL changes', () => {
useGlobalSessionsStore.getState().upsertSession(buildSession('https://share.example/a'));
useGlobalSessionsStore.getState().upsertSession(buildSession('https://share.example/b'));
expect(useGlobalSessionsStore.getState().activeSessions[0]?.share?.url).toBe('https://share.example/b');
});
});
@@ -76,7 +76,7 @@ const getSessionSignature = (session: Session): string => {
session.time?.created ?? 0,
session.time?.updated ?? 0,
session.time?.archived ?? 0,
session.share ? 1 : 0,
session.share?.url ?? '',
resolveGlobalSessionDirectory(session) ?? '',
].join(':');
};