Jelajahi Sumber

fix(agents): restore display names from CR annotations

Agent annotations are written under agents.locostack.com but read from locostack.com, causing the UI to fall back to metadata.name.

- Read name, icon, description, and tags from the matching annotation prefix
- Add a CR round-trip regression test for Chinese display names and metadata
- Targeted Vitest test and ESLint checks pass
KongLingTT 1 bulan lalu
induk
melakukan
a3f7608c00

+ 32 - 0
src/lib/types/custom-resources/agent.test.ts

@@ -0,0 +1,32 @@
+import { describe, expect, it } from 'vitest';
+
+import type { Agent } from '$lib/types/entities';
+
+import { fromAgentCR, toAgentCR } from './agent';
+
+const agent: Agent = {
+	id: 'paas-48fb9d-agent-1ea2784d',
+	stack: 'default',
+	name: '米塔',
+	icon: 'bot',
+	description: '可爱助手',
+	tags: ['中文', 'assistant'],
+	systemPrompt: '你的名字是米塔',
+	model: { type: 'external', id: 'deepseek-v4-1-flash', name: 'deepseek-v4-1-flash' },
+	skills: [],
+	tools: [],
+	kbs: [],
+	subagents: [],
+	runtime: { name: 'lambdagent' },
+};
+
+describe('Agent CR annotations', () => {
+	it('round-trips the display name and metadata through agents.locostack.com annotations', () => {
+		const restored = fromAgentCR(toAgentCR(agent));
+
+		expect(restored.name).toBe('米塔');
+		expect(restored.icon).toBe('bot');
+		expect(restored.description).toBe('可爱助手');
+		expect(restored.tags).toEqual(['中文', 'assistant']);
+	});
+});

+ 1 - 1
src/lib/types/custom-resources/agent.ts

@@ -16,7 +16,7 @@ const agentAnnotation = (key: string, value: string | undefined): { [key: string
 	value ? { [`agents.locostack.com/${key}`]: value } : {};
 
 const readAgentAnnotation = (metadata: V1ObjectMeta, key: string): string | undefined =>
-	metadata.annotations?.[`locostack.com/${key}`];
+	metadata.annotations?.[`agents.locostack.com/${key}`];
 
 const agentAnnotations = (agent: Agent): { [key: string]: string } => ({
 	...agentAnnotation('name', agent.name),