🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { describe, expect, it } from 'vitest';
import { resolveAgentTopicGroupMode, resolveProjectTopicGroupMode } from './topicGroupMode';
describe('resolveAgentTopicGroupMode', () => {
it('defaults Claude Code agents to project grouping', () => {
expect(
resolveAgentTopicGroupMode({
agentType: 'claude-code',
globalMode: 'byTime',
}),
).toBe('byProject');
});
it('defaults Codex agents to project grouping', () => {
expect(
resolveAgentTopicGroupMode({
agentType: 'codex',
globalMode: 'byTime',
}),
).toBe('byProject');
});
it.each(['amp', 'codebuddy', 'droid', 'opencode', 'pi', 'qoder', 'trae'] as const)(
'defaults %s agents to project grouping',
(agentType) => {
expect(
resolveAgentTopicGroupMode({
agentType,
globalMode: 'byTime',
}),
).toBe('byProject');
},
);
it('keeps remote heterogeneous agents on the global default grouping', () => {
expect(
resolveAgentTopicGroupMode({
agentType: 'openclaw',
globalMode: 'byTime',
}),
).toBe('byTime');
expect(
resolveAgentTopicGroupMode({
agentType: 'hermes',
globalMode: 'flat',
}),
).toBe('flat');
});
it('keeps normal agents on the global default grouping', () => {
expect(resolveAgentTopicGroupMode({ globalMode: 'byTime' })).toBe('byTime');
});
it('keeps Claude Code agents on project grouping when the global selection changes', () => {
expect(
resolveAgentTopicGroupMode({
agentType: 'claude-code',
globalMode: 'flat',
}),
).toBe('byProject');
});
it('uses the global selection for normal agents', () => {
expect(resolveAgentTopicGroupMode({ globalMode: 'flat' })).toBe('flat');
});
it('uses the agent chat config selection when present', () => {
expect(
resolveAgentTopicGroupMode({
agentTopicGroupMode: 'byTime',
agentType: 'codex',
globalMode: 'byTime',
}),
).toBe('byTime');
});
/** @example byAgent picked in a project sidebar must not leak into a single agent's own sidebar. */
it.each([{ agentTopicGroupMode: undefined }, { agentTopicGroupMode: 'byAgent' as const }])(
'normalizes byAgent to byTime for unscoped agent sidebars (config %o)',
({ agentTopicGroupMode }) => {
// ROOT CAUSE: the project sidebar persists byAgent into the global
// preference and (before this fix) the per-agent config could hold it
// too; a single agent's topics then rendered as one self-named bucket.
// Project-scoped lists read the global mode directly and keep byAgent.
expect(
resolveAgentTopicGroupMode({
agentTopicGroupMode,
globalMode: 'byAgent',
}),
).toBe('byTime');
},
);
/** @example an agent's own sidebar groups by device too: its topics place by bound device or project directory. */
it.each([
{ agentTopicGroupMode: undefined, globalMode: 'byDevice' as const },
{ agentTopicGroupMode: 'byDevice' as const, globalMode: 'byTime' as const },
])('keeps byDevice for unscoped agent sidebars (%o)', ({ agentTopicGroupMode, globalMode }) => {
expect(resolveAgentTopicGroupMode({ agentTopicGroupMode, globalMode })).toBe('byDevice');
});
});
describe('resolveProjectTopicGroupMode', () => {
/** @example a stale byProject must not turn a project's own list into one bucket. */
it('normalizes byProject to byAgent', () => {
expect(resolveProjectTopicGroupMode('byProject')).toBe('byAgent');
});
it.each(['byStatus', 'byTime', 'byAgent', 'byDevice', 'flat'] as const)('keeps %s', (mode) => {
expect(resolveProjectTopicGroupMode(mode)).toBe(mode);
});
});