Two product decisions from tonight: 1. Public AI providers can now be published by an admin as named presets (lib/ai/types.ts's PublicAiPreset: name/baseUrl/model/apiKeyEnvVar). The admin names an env var, never a secret value - the actual key is whatever ops has set in the server's real environment, same custody model as the existing AI_SERVER_BASE_URL var. A new server route (app/api/ai/public/chat) resolves it and makes the call itself, which also sidesteps the CORS/wrong-base-URL failure class chatPublic hit earlier tonight. Users pick a preset from a dropdown in Settings - Answer with - no key field at all; personal BYOK (paste your own key) stays available as a secondary "Add your own key" option, not removed. Admin UI: new "Public - org-managed presets" card in the AI policy tab. 2. AI now defaults ON instead of requiring setup (lib/ai/auto-provision.ts): on first load, if no provider is chosen yet, probe OpenCode (this app auto-spawns `opencode serve` itself, so it's the one local option with zero external install step) then Ollama via the existing auto-discovery, and adopt whichever answers. Never overrides an explicit choice - only fires while provider is still null. Wired into both AI entry points (the Ask button and the Settings pane) so it resolves before either renders its "not configured" state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
23 lines
876 B
TypeScript
23 lines
876 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { presetActiveId, isPresetActiveId, presetIdFromActiveId } from '../local-settings';
|
|
|
|
describe('preset active-id helpers', () => {
|
|
it('round-trips a preset id through the prefixed activeProfileId space', () => {
|
|
const activeId = presetActiveId('preset-abc123');
|
|
expect(activeId).toBe('preset:preset-abc123');
|
|
expect(isPresetActiveId(activeId)).toBe(true);
|
|
expect(presetIdFromActiveId(activeId)).toBe('preset-abc123');
|
|
});
|
|
|
|
it('does not mistake a personal profile id for a preset id', () => {
|
|
const profileId = 'profile-xyz789-abc123';
|
|
expect(isPresetActiveId(profileId)).toBe(false);
|
|
expect(presetIdFromActiveId(profileId)).toBeNull();
|
|
});
|
|
|
|
it('handles null safely', () => {
|
|
expect(isPresetActiveId(null)).toBe(false);
|
|
expect(presetIdFromActiveId(null)).toBeNull();
|
|
});
|
|
});
|