fix(channel): support channel names that include numbers; legacy test names containing numbers may still appear (#796)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
Haze
2026-04-08 18:38:59 +08:00
committed by GitHub
Unverified
parent 19b3ea974b
commit c1e165d48d
6 changed files with 219 additions and 29 deletions

View File

@@ -458,4 +458,25 @@ describe('agent config lifecycle', () => {
expect(snapshot.channelAccountOwners['feishu:default']).toBeUndefined();
expect(snapshot.channelAccountOwners['telegram:default']).toBe('main');
});
it('avoids numeric-only ids when creating agents from CJK names', async () => {
await writeOpenClawJson({
agents: {
list: [{ id: 'main', name: 'Main', default: true }],
},
});
const { createAgent, listAgentsSnapshot } = await import('@electron/utils/agent-config');
await createAgent('测试2');
await createAgent('测试1');
const snapshot = await listAgentsSnapshot();
const agentIds = snapshot.agents.map((agent) => agent.id);
expect(agentIds).toContain('agent');
expect(agentIds).toContain('agent-2');
expect(agentIds).not.toContain('2');
expect(agentIds).not.toContain('1');
});
});