mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-02 12:13:05 +00:00
DesktopController is a route root that had grown a controller's worth of session-list plumbing inline. Extract the cohesive fetch/paging cluster into a focused hook and a tested pure helper, per AGENTS.md's "keep route roots thin" guidance: - use-session-list-actions.ts: refreshSessions / loadMoreSessions / loadMoreSessionsForProfile / loadMoreMessagingForPlatform / refreshCronJobs (plus the private cron/messaging refreshers, sessionsToKeep, and the excluded-source constants) - desktop-controller-utils.ts: pure sameCronSignature helper (+ unit tests) Pure restructuring, no behavior change. desktop-controller.tsx: 1,441 -> 1,233.
31 lines
1,023 B
TypeScript
31 lines
1,023 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import type { SessionInfo } from '@/hermes'
|
|
|
|
import { sameCronSignature } from './desktop-controller-utils'
|
|
|
|
const session = (id: string, title: string | null): SessionInfo => ({ id, title }) as SessionInfo
|
|
|
|
describe('sameCronSignature', () => {
|
|
it('is false when the lengths differ', () => {
|
|
expect(sameCronSignature([session('a', 't')], [])).toBe(false)
|
|
})
|
|
|
|
it('is true when ids and titles match in order', () => {
|
|
const a = [session('a', 'one'), session('b', 'two')]
|
|
const b = [session('a', 'one'), session('b', 'two')]
|
|
expect(sameCronSignature(a, b)).toBe(true)
|
|
})
|
|
|
|
it('is false when a title changed', () => {
|
|
const a = [session('a', 'one')]
|
|
const b = [session('a', 'renamed')]
|
|
expect(sameCronSignature(a, b)).toBe(false)
|
|
})
|
|
|
|
it('is false when order differs', () => {
|
|
const a = [session('a', 't'), session('b', 't')]
|
|
const b = [session('b', 't'), session('a', 't')]
|
|
expect(sameCronSignature(a, b)).toBe(false)
|
|
})
|
|
})
|