mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-26 22:30:50 +00:00
* feat(web): searchable session picker on share target (#980) Add search to the Android share-target picker so operators can attach shared content to inactive or older sessions, not just recent actives. Reuses sidebar search helpers; caps default active list with a search hint. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): defer share pending consume until session is active ShareSeedConsumer was consuming the sessionStorage transfer id on first mount even when the target session was inactive. Reopening into a new session id remounted the chat with the key already gone, dropping the shared payload. Consume and seed only after sessionActive is true. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): bind share pending transfer to target session id Deferring consume until active left a global pending slot that the next unrelated active SessionChat could claim. Bind the pending transfer to the picked session id, retarget on reopen/spawn id-swap, and only consume when the mounting session matches. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): wire SessionListSearch date-range props on share picker Upstream added required customStart/customEnd/onDateRangeChange to SessionListSearch; share /share must pass them and honor the range when filtering sessions after rebase onto v0.23.1. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): pass sessionActivityDates to share SessionListSearch Upstream SessionListSearch now requires activity dates for the date picker; without them CI typecheck fails and the PR chip stays needs_work. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): use cached machine labels in share picker search Share picker now uses useMachineLabels like SessionList so stale machine ids still match search by display name. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): align share picker with sidebar session prep and preview limit Snapshot via prepareSidebarSessions and pass useSessionPreviewLimit so search targets and fold cap match the main session list. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): wire SessionListSearch expanded props on share picker Upstream search now requires expanded/onExpandedChange; default open on the share picker so the field is available immediately. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): unblock typecheck after SessionSummary and RawSendError fields Fill new required SessionSummary watermarks in the share picker test helper, and set deliveryMode on abort-restore send errors. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): mock machines hooks in share page missing-state test SharePage now calls useMachines for picker search labels; the missing- share unit test needs those hooks stubbed without a QueryClient. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): retarget pending share on automatic session supersession When SessionDetailRoute follows supersededBySessionId A→B, rewrite the share pending target so ShareSeedConsumer on B can still claim it. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Debian <heavygee@oos-linux.in.lockhouse>
58 lines
2.3 KiB
TypeScript
58 lines
2.3 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest'
|
|
import {
|
|
SHARE_PENDING_TRANSFER_KEY,
|
|
consumeSharePendingTransfer,
|
|
peekSharePendingTransfer,
|
|
retargetSharePendingTransfer,
|
|
setSharePendingTransfer,
|
|
} from './sharePendingState'
|
|
|
|
afterEach(() => {
|
|
try { window.sessionStorage.clear() } catch { /* noop */ }
|
|
})
|
|
|
|
describe('sharePendingState', () => {
|
|
it('round-trips a transfer id bound to a session and clears on consume', () => {
|
|
setSharePendingTransfer('xfer-1', 'session-a')
|
|
expect(peekSharePendingTransfer()).toEqual({ transferId: 'xfer-1', sessionId: 'session-a' })
|
|
|
|
const first = consumeSharePendingTransfer('session-a')
|
|
expect(first).toBe('xfer-1')
|
|
|
|
const second = consumeSharePendingTransfer('session-a')
|
|
expect(second).toBeNull()
|
|
})
|
|
|
|
it('does not let a different session steal a bound pending transfer', () => {
|
|
setSharePendingTransfer('xfer-bound', 'session-a')
|
|
expect(consumeSharePendingTransfer('session-b')).toBeNull()
|
|
expect(window.sessionStorage.getItem(SHARE_PENDING_TRANSFER_KEY)).not.toBeNull()
|
|
expect(consumeSharePendingTransfer('session-a')).toBe('xfer-bound')
|
|
})
|
|
|
|
it('retargets the pending session id across reopen id-swap', () => {
|
|
setSharePendingTransfer('xfer-1', 'session-a')
|
|
retargetSharePendingTransfer('session-a', 'session-b')
|
|
expect(peekSharePendingTransfer()).toEqual({ transferId: 'xfer-1', sessionId: 'session-b' })
|
|
expect(consumeSharePendingTransfer('session-a')).toBeNull()
|
|
expect(consumeSharePendingTransfer('session-b')).toBe('xfer-1')
|
|
})
|
|
|
|
it('returns null when no transfer is pending', () => {
|
|
expect(consumeSharePendingTransfer('any')).toBeNull()
|
|
})
|
|
|
|
it('overwrites a stale id rather than appending', () => {
|
|
setSharePendingTransfer('a', 'session-a')
|
|
setSharePendingTransfer('b', 'session-a')
|
|
expect(consumeSharePendingTransfer('session-a')).toBe('b')
|
|
expect(consumeSharePendingTransfer('session-a')).toBeNull()
|
|
})
|
|
|
|
it('claims a legacy unbound bare transfer id string', () => {
|
|
window.sessionStorage.setItem(SHARE_PENDING_TRANSFER_KEY, 'legacy-xfer')
|
|
expect(consumeSharePendingTransfer('session-any')).toBe('legacy-xfer')
|
|
expect(consumeSharePendingTransfer('session-any')).toBeNull()
|
|
})
|
|
})
|