Refresh AITURK model discovery automatically in desktop beta 4

This commit is contained in:
2026-09-06 01:37:27 +03:00
parent aa498f4cbb
commit 237d1e2060
8 changed files with 111 additions and 10 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "aiturk-ide",
"productName": "AITURK IDE",
"private": true,
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "TurkServis resmi yapay zekâ geliştirme ortamı. Hermes Agent tabanlıdır.",
"author": "AITURK / TurkServis",
"repository": {
@@ -103,7 +103,7 @@ describe('the catalog owns model curation', () => {
renderMenu()
await screen.findByText(/Gemini 2\.5 Flash/i)
const input = screen.getByRole('textbox', { name: 'Search models' })
const input = screen.getByRole('textbox', { name: /Search models|Model ara/ })
fireEvent.change(input, { target: { value: 'gemini-3.1' } })
@@ -116,7 +116,7 @@ describe('the catalog owns model curation', () => {
renderMenu()
await screen.findByText(/Gemini 3\.1 Pro/i)
fireEvent.click(screen.getByText('Edit models…'))
fireEvent.click(screen.getByText(/Edit models…|Modelleri düzenle…/))
expect($modelVisibilityOpen.get()).toBe(true)
})
+25 -1
View File
@@ -1,4 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { QueryObserver, focusManager } from '@tanstack/react-query'
import { invalidateProfileScopedQueries, queryClient } from './query-client'
@@ -11,6 +12,29 @@ describe('invalidateProfileScopedQueries', () => {
queryClient.clear()
})
it('refreshes an observed model list without reopening the picker', async () => {
vi.useFakeTimers()
focusManager.setFocused(true)
let models = ['old-model']
const observer = new QueryObserver(queryClient, {
queryKey: ['model-options', 'selected-profile'],
queryFn: async () => models
})
const unsubscribe = observer.subscribe(() => {})
try {
await observer.refetch()
expect(observer.getCurrentResult().data).toEqual(['old-model'])
models = ['new-model', 'new-combo']
await vi.advanceTimersByTimeAsync(60_000)
expect(observer.getCurrentResult().data).toEqual(models)
} finally {
unsubscribe()
queryClient.clear()
focusManager.setFocused(undefined)
vi.useRealTimers()
}
})
it('invalidates profile-scoped caches and leaves account/global caches intact', () => {
const profileScoped = [
['hermes-config-record'],
+6
View File
@@ -12,6 +12,12 @@ export const queryClient = new QueryClient({
}
})
queryClient.setQueryDefaults(['model-options'], {
staleTime: 30_000,
refetchInterval: 60_000,
refetchOnWindowFocus: true
})
// Curried, setState-shaped cache writer for optimistic write-through: keeps
// mutation sites terse (`setX(next)` or `setX(prev => …)`) over one query key.
export const writeCache =