Skip to content

The agent that grows with you

style(kanban): satisfy the curly and blank-line lint rules in the alias-resolution change

Brooklyn Nicholsonbbf670a98de6
diff --git a/apps/desktop/src/plugins/kanban/api.default-notify.test.ts b/apps/desktop/src/plugins/kanban/api.default-notify.test.ts
index ba5522b4368..1d56805a70b 100644
--- a/apps/desktop/src/plugins/kanban/api.default-notify.test.ts
+++ b/apps/desktop/src/plugins/kanban/api.default-notify.test.ts
@@ -44,16 +44,20 @@ describe('default board event notifications', () => {
{ get: (_key, fallback) => fallback, set: vi.fn(), remove: vi.fn() },
(_path, callback) => {
frame = callback
+
return vi.fn()
}
)
let revision = 1
+
const observer = new QueryObserver(queryClient, {
queryKey: taskKey('local', '', 'task'),
queryFn: async () => ({ revision }),
staleTime: Infinity
})
+
const unsubscribe = observer.subscribe(() => undefined)
+
try {
await vi.waitFor(() => expect(observer.getCurrentResult().data).toEqual({ revision: 1 }))
await vi.waitFor(() => expect(frame).toBeTypeOf('function'))
@@ -68,11 +72,14 @@ describe('default board event notifications', () => {
it.each(['empty', 'rejected'])('preserves the live alias socket when board resolution is %s', async mode => {
const rest = vi.fn(async (path: string) => {
if (path === '/boards') {
- if (mode === 'rejected') throw new Error('offline')
+ if (mode === 'rejected') {throw new Error('offline')}
+
return { current: '' }
}
+
return { latest_event_id: 20 }
})
+
const socket = vi.fn(() => vi.fn())
dispose = bindApi(rest as never, { get: (_key, fallback) => fallback, set: vi.fn(), remove: vi.fn() }, socket)
await vi.waitFor(() => expect(socket).toHaveBeenCalledWith('/events?since=20', expect.any(Function)))
@@ -81,12 +88,15 @@ describe('default board event notifications', () => {
it.each(['selection', 'dispose'])('ignores alias resolution after %s', async change => {
let resolveBoards!: (value: unknown) => void
+
const boards = new Promise(resolve => {
resolveBoards = resolve
})
+
const rest = vi.fn(async (path: string) => (path === '/boards' ? boards : { latest_event_id: 30 }))
const socket = vi.fn(() => vi.fn())
dispose = bindApi(rest as never, { get: (_key, fallback) => fallback, set: vi.fn(), remove: vi.fn() }, socket)
+
if (change === 'selection') {
$boardSlug.set('chosen')
await vi.waitFor(() => expect(socket).toHaveBeenCalledWith('/events?board=chosen&since=30', expect.any(Function)))
@@ -94,6 +104,7 @@ describe('default board event notifications', () => {
dispose()
dispose = undefined
}
+
resolveBoards({ current: 'late' })
await new Promise(resolve => setTimeout(resolve, 0))
expect(socket).toHaveBeenCalledTimes(change === 'selection' ? 1 : 0)
@@ -118,16 +129,22 @@ describe('default board event notifications', () => {
it('pins the socket to the resolved board and notifies a post-baseline blocked event once', async () => {
const callbacks: Array<(data: unknown) => void> = []
+
const socket = vi.fn((_path: string, cb: (data: unknown) => void) => {
callbacks.push(cb)
+
return vi.fn()
})
+
let latest = 100
+
const rest = vi.fn(async (path: string) => {
- if (path === '/boards') return { current: 'default', boards: [{ slug: 'default' }] }
- if (path === '/board?board=default' || path === '/board') return { latest_event_id: latest }
+ if (path === '/boards') {return { current: 'default', boards: [{ slug: 'default' }] }}
+
+ if (path === '/board?board=default' || path === '/board') {return { latest_event_id: latest }}
throw new Error(`Unexpected REST call: ${path}`)
})
+
const storage = { get: <T>(_key: string, fallback: T) => fallback, set: vi.fn(), remove: vi.fn() }
dispose = bindApi(rest as never, storage, socket)
await vi.waitFor(() => expect(callbacks).toHaveLength(1))
diff --git a/apps/desktop/src/plugins/kanban/api.ts b/apps/desktop/src/plugins/kanban/api.ts
index 345b7570193..fc165dda8f6 100644
--- a/apps/desktop/src/plugins/kanban/api.ts
+++ b/apps/desktop/src/plugins/kanban/api.ts
@@ -179,6 +179,7 @@ function onEventsFrame(scope: string, slug: string, data: unknown, selectedSlug
for (const taskId of new Set(events.map(event => event.task_id).filter(Boolean))) {
void queryClient.invalidateQueries({ queryKey: taskKey(scope, slug, taskId!) })
+
if (selectedSlug !== slug) {
void queryClient.invalidateQueries({ queryKey: taskKey(scope, selectedSlug, taskId!) })
}
@@ -235,7 +236,7 @@ export function bindApi(
const selectedSlug = $boardSlug.get()
return socket(eventsUrl(slug, since), data => {
- if (generation === socketGeneration) onEventsFrame(scope, slug, data, selectedSlug)
+ if (generation === socketGeneration) {onEventsFrame(scope, slug, data, selectedSlug)}
})
}
@@ -288,6 +289,7 @@ export function bindApi(
if (selectedSlug) {
openResolved(selectedSlug)
+
return
}