mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-13 04:59:51 +08:00
refactor(settings): remove wrapper layers, dead props and unused dictionary keys
- components/model-selector.tsx uses Dialog, Command and Tooltip directly; delete components/ai-elements/model-selector.tsx and components/button-with-tooltip.tsx; one renderGroups for both lists; no "Server · " prefix round trip - components/ui: drop CommandDialog, CommandShortcut and six unused shadcn exports - model-config-dialog: no type-to-confirm on provider delete; provider-credentials-fields: drop footer and bedrockApiKey - hooks/use-model-config.ts and lib/types/model-config.ts: remove the 2025-12 single-provider migration, resetConfig, selectedModel and fields nothing reads - components/chat/TemplateFormDialog.tsx replaces the create and edit dialogs; TemplatePanel drops the setInput fallback, the templatesChanged listener, dictionary fallbacks and formatLastUsed; lib/template-storage.ts drops getTemplate, clickCount and indexes - reasoning.tsx becomes one component; shimmer uses a CSS keyframe (motion and @radix-ui/react-use-controllable-state removed) - error-toast.tsx deleted in favour of toast.error; ValidationCard drops the idle status; dev-xml-simulator uses English literals - admin: no enum setting type, shared types from lib/admin (AdminProviderInput stays exported for that), ENABLE_HISTORY_XML_REPLACE entry removed - app/globals.css: drop check-pop, --ease-spring, --duration-normal and the shadow aliases - dictionaries: 81 unused keys removed from all four languages
This commit is contained in:
@@ -37,7 +37,6 @@ describe("sortTemplates", () => {
|
||||
prompt: "test prompt",
|
||||
createdAt: 1000,
|
||||
updatedAt: 1000,
|
||||
clickCount: 0,
|
||||
runCount: 0,
|
||||
lastUsedAt: 0,
|
||||
pinned: false,
|
||||
@@ -115,7 +114,6 @@ describe("searchTemplates", () => {
|
||||
description: "Basic flowchart template",
|
||||
createdAt: 1000,
|
||||
updatedAt: 1000,
|
||||
clickCount: 0,
|
||||
runCount: 0,
|
||||
lastUsedAt: 0,
|
||||
pinned: false,
|
||||
@@ -127,7 +125,6 @@ describe("searchTemplates", () => {
|
||||
description: "Entity relationship diagram",
|
||||
createdAt: 1000,
|
||||
updatedAt: 1000,
|
||||
clickCount: 0,
|
||||
runCount: 0,
|
||||
lastUsedAt: 0,
|
||||
pinned: false,
|
||||
@@ -138,7 +135,6 @@ describe("searchTemplates", () => {
|
||||
prompt: "Draw network topology",
|
||||
createdAt: 1000,
|
||||
updatedAt: 1000,
|
||||
clickCount: 0,
|
||||
runCount: 0,
|
||||
lastUsedAt: 0,
|
||||
pinned: false,
|
||||
@@ -236,7 +232,6 @@ describe("validateImportData", () => {
|
||||
prompt: "test prompt",
|
||||
createdAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
clickCount: 0,
|
||||
runCount: 0,
|
||||
lastUsedAt: 0,
|
||||
pinned: false,
|
||||
|
||||
@@ -260,45 +260,3 @@ describe("useModelConfig across tabs", () => {
|
||||
expect(result.current.config.providers).toHaveLength(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useModelConfig migration", () => {
|
||||
const OLD = {
|
||||
provider: "next-ai-draw-io-ai-provider",
|
||||
baseUrl: "next-ai-draw-io-ai-base-url",
|
||||
apiKey: "next-ai-draw-io-ai-api-key",
|
||||
model: "next-ai-draw-io-ai-model",
|
||||
}
|
||||
|
||||
it("moves an old keyless Ollama setup into the new format", async () => {
|
||||
localStorage.setItem(OLD.provider, "ollama")
|
||||
localStorage.setItem(OLD.baseUrl, "http://localhost:11434/api")
|
||||
localStorage.setItem(OLD.apiKey, "")
|
||||
localStorage.setItem(OLD.model, "llama3.2")
|
||||
const { result } = await renderLoaded()
|
||||
const [provider] = result.current.config.providers
|
||||
expect(provider).toMatchObject({
|
||||
provider: "ollama",
|
||||
apiKey: "",
|
||||
baseUrl: "http://localhost:11434/api",
|
||||
models: [{ modelId: "llama3.2" }],
|
||||
})
|
||||
expect(result.current.selectedModelId).toBe(provider.models[0].id)
|
||||
expect(localStorage.getItem(OLD.model)).toBeNull()
|
||||
})
|
||||
|
||||
it("keeps an old Ollama without a URL on the server's Ollama", async () => {
|
||||
localStorage.setItem(OLD.provider, "ollama")
|
||||
localStorage.setItem(OLD.apiKey, "")
|
||||
localStorage.setItem(OLD.model, "llama3.2")
|
||||
const { result } = await renderLoaded()
|
||||
// No cloud address: the request takes OLLAMA_BASE_URL or this machine
|
||||
expect(result.current.config.providers[0].baseUrl).toBe("")
|
||||
})
|
||||
|
||||
it("still needs a key for other providers", async () => {
|
||||
localStorage.setItem(OLD.provider, "openai")
|
||||
localStorage.setItem(OLD.model, "gpt-4o")
|
||||
const { result } = await renderLoaded()
|
||||
expect(result.current.config.providers).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user