The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
import { describe, expect, it } from 'vitest'
import { editingKey } from '../../stores/neuronStore'
import {
backendNote,
clampStrength,
effectiveStrengths,
entriesFor,
hasPersonaProfile,
jobProgressText,
jobShare,
personaProfileKey,
sameEntries,
shortDuration,
strengthWarning,
warningText,
tweakedModelNote,
buildTimeNote,
} from '../neuron'
import type { NeuronJob } from '../../api/neuron'
import type { Profiles } from '../neuron'
const job = (over: Partial<NeuronJob>): NeuronJob => ({
status: 'running', kind: 'build', title: '', modelPath: '/m.gguf', phaseLabel: '', step: 0, total: 0,
bytesDone: 0, bytesTotal: 0, rateBps: 0, etaSecs: null, elapsedSecs: 0, resultId: null, error: null, logs: [],
...over,
})
describe('neuron profiles', () => {
const profiles: Profiles = {
'qwen-1': { creative: 0.5 },
[personaProfileKey('qwen-1', 'pirate')]: { casual: 1 },
}
it('uses the persona profile when there is one, else the model profile', () => {
expect(effectiveStrengths(profiles, 'qwen-1', 'pirate')).toEqual({ casual: 1 })
expect(effectiveStrengths(profiles, 'qwen-1', 'unrestricted')).toEqual({ creative: 0.5 })
expect(effectiveStrengths(profiles, 'qwen-1', null)).toEqual({ creative: 0.5 })
expect(effectiveStrengths(profiles, 'other', 'pirate')).toEqual({})
expect(hasPersonaProfile(profiles, 'qwen-1', 'pirate')).toBe(true)
expect(hasPersonaProfile(profiles, 'qwen-1', 'x')).toBe(false)
})
it('sends only sliders that are on and computed, sorted', () => {
const entries = entriesFor({ b: 0.3, a: -0.5, off: 0, missing: 1, tiny: 0.01 }, new Set(['a', 'b', 'off', 'tiny']))
expect(entries).toEqual([{ id: 'a', strength: -0.5 }, { id: 'b', strength: 0.3 }])
})
it('clamps and snaps the middle to exactly zero', () => {
expect(clampStrength(3)).toBe(1)
expect(clampStrength(-3)).toBe(-1)
expect(clampStrength(0.011)).toBe(0)
expect(clampStrength(Number.NaN)).toBe(0)
expect(clampStrength(0.333)).toBe(0.33)
})
it('compares entry lists by value', () => {
expect(sameEntries([{ id: 'a', strength: 0.5 }], [{ id: 'a', strength: 0.5 }])).toBe(true)
expect(sameEntries([{ id: 'a', strength: 0.5 }], [{ id: 'a', strength: 0.6 }])).toBe(false)
expect(sameEntries([], [])).toBe(true)
})
})
describe('neuron warnings', () => {
it('warns at high strength and louder with several strong sliders', () => {
expect(strengthWarning([{ id: 'a', strength: 0.5 }])).toBeNull()
expect(strengthWarning([{ id: 'a', strength: 0.9 }])).toBe('strong')
expect(strengthWarning([{ id: 'a', strength: 0.6 }, { id: 'b', strength: -0.6 }])).toBe('strong')
expect(strengthWarning([{ id: 'a', strength: 1 }, { id: 'b', strength: 0.8 }])).toBe('overload')
})
it('says that a strong push costs Agent and Code their task (measured: +0.4 works, +1.0 ignored it)', () => {
expect(warningText('strong')).toMatch(/Agent and Code tasks work better at about ±0\.5/)
expect(warningText('overload')).toMatch(/Agent and Code may stop following the task/)
expect(warningText(null)).toBeNull()
})
it('names the backend that cannot be steered', () => {
expect(backendNote('lu-engine')).toBeNull()
expect(backendNote('ollama')).toMatch(/Ollama takes no control vectors/)
expect(backendNote('cloud')).toMatch(/Cloud/)
})
})
describe('neuron progress', () => {
it('reads a download like the other downloads: MB, %, speed, time left', () => {
const j = job({ kind: 'download', bytesDone: 12e6, bytesTotal: 42e6, rateBps: 3.1e6, etaSecs: 9 })
expect(jobProgressText(j)).toBe('12 MB of 42 MB · 29% · 3.1 MB/s · 9 s left')
})
it('reads a computation as examples and steps', () => {
expect(jobProgressText(job({ phaseLabel: 'Reading the examples through the model', step: 12, total: 40, etaSecs: 20 })))
.toBe('Example 12 of 40 · 30% · 20 s left')
expect(jobProgressText(job({ phaseLabel: 'Finding the strongest setting', step: 3, total: 12, etaSecs: 70 })))
.toBe('Step 3 of 12 · 25% · 1 min left')
expect(jobProgressText(job({ elapsedSecs: 5 }))).toBe('running for 5 s')
})
it('knows its share only when something is counted', () => {
expect(jobShare(job({}))).toBeNull()
expect(jobShare(job({ step: 5, total: 10 }))).toBe(0.5)
expect(jobShare(job({ bytesDone: 50, bytesTotal: 100, step: 1, total: 10 }))).toBe(0.5)
})
it('writes durations short', () => {
expect(shortDuration(42)).toBe('42 s')
expect(shortDuration(150)).toBe('3 min')
expect(shortDuration(3900)).toBe('1 h 5 min')
})
})
describe('editingKey', () => {
it('is the persona key only while a persona steers', () => {
expect(editingKey('m', 'pirate', 'persona')).toBe('m::persona:pirate')
expect(editingKey('m', undefined, 'persona')).toBe('m')
expect(editingKey('m', 'pirate', 'model')).toBe('m')
})
})
// P11 FEHLER 10 (David, 31.10.2026): a model changed before gets a friendly
// note before computing, with the original to take instead.
describe('the note for a tweaked model', () => {
it('names why and offers the original', () => {
const note = tweakedModelNote({ tweaked: ['fine-tune', 'merge', 'heretic'], original: 'Qwen3.5 9B' })!
expect(note.title).toBe('Works best with original, untweaked models')
expect(note.text).toMatch(/fine-tune, merge, heretic/)
expect(note.original).toBe('Qwen3.5 9B')
})
it('says nothing for an original model', () => {
expect(tweakedModelNote({ tweaked: [], original: 'Qwen2.5 0.5B' })).toBeNull()
})
})
// I1 on the box (31.10.2026): one slider took ~25 min on Windows with the
// CPU-only vector tool, and nothing said so before. The page now says how
// long it will take, before the start, whenever it is more than a moment.
describe('the time a slider takes, said before computing', () => {
it('says nothing when it is quick', () => {
expect(buildTimeNote({ lowSecs: 20, highSecs: 110, measured: false })).toBeNull()
})
it('gives the range, why, and that it can be stopped', () => {
const note = buildTimeNote({ lowSecs: 741, highSecs: 3023, measured: false })!
expect(note.title).toBe('This takes a while on this PC')
expect(note.text).toContain('about 12–50 min for one slider')
expect(note.text).toMatch(/slow on this PC/)
expect(note.text).toMatch(/stop it any time/)
})
it('says when the range comes from a run on this PC', () => {
const note = buildTimeNote({ lowSecs: 1176, highSecs: 2297, measured: true })!
expect(note.text).toContain('about 20–38 min for one slider')
expect(note.text).toMatch(/last run on this PC/)
})
it('reads across units', () => {
expect(buildTimeNote({ lowSecs: 1800, highSecs: 7300, measured: false })!.text).toContain('about 30 min to 2 h 2 min')
})
})