feat: discover docker compose deps for dashboard

This commit is contained in:
William Valentin
2026-02-22 20:22:37 -08:00
parent ba6abfb078
commit 58eee60023
5 changed files with 460 additions and 187 deletions
+22 -2
View File
@@ -137,6 +137,17 @@ function createMockClient() {
containerName: 'flynn-whisper-server-1',
availableActions: ['restart', 'stop', 'update'],
},
{
id: 'brave-search',
name: 'Brave Search',
service: 'brave-search',
configured: true,
state: 'running',
health: 'healthy',
statusText: 'Up 2 minutes',
containerName: 'brave-search',
availableActions: ['restart', 'stop', 'update'],
},
],
calls: [] as Array<{ method: string; params?: Record<string, unknown> }>,
};
@@ -275,7 +286,7 @@ function createMockClient() {
dependency.state = 'running';
dependency.health = 'healthy';
dependency.statusText = 'running (healthy)';
dependency.containerName = 'whisper-server';
dependency.containerName = String(dependency.service ?? dependency.id ?? '');
dependency.availableActions = ['restart', 'stop', 'update'];
} else if (action === 'stop') {
dependency.state = 'stopped';
@@ -533,7 +544,9 @@ describe('DashboardPage assistant controls', () => {
const card = container.querySelector('#ops-docker-dependencies');
expect(card).toBeTruthy();
expect(String(card.textContent ?? '')).toContain('Whisper (whisper.cpp)');
expect(String(card.textContent ?? '')).toContain('Brave Search');
expect(String(card.textContent ?? '')).toContain('whisper-server');
expect(String(card.textContent ?? '')).toContain('brave-search');
expect(String(card.textContent ?? '')).toContain('Up 2 minutes (healthy)');
});
@@ -562,12 +575,19 @@ describe('DashboardPage assistant controls', () => {
updateBtn.dispatchEvent(new windowObj.Event('click', { bubbles: true }));
await flush();
const braveRestartBtn = container.querySelector('#ops-docker-dependencies .docker-dependency-action-btn[data-dependency-id="brave-search"][data-action="restart"]');
expect(braveRestartBtn).toBeTruthy();
braveRestartBtn.dispatchEvent(new windowObj.Event('click', { bubbles: true }));
await flush();
const dependencyCalls = state.calls.filter((entry) => entry.method === 'system.dockerDependencyControl');
expect(dependencyCalls).toHaveLength(4);
expect(dependencyCalls).toHaveLength(5);
expect(dependencyCalls[0].params).toEqual({ dependency: 'whisper', action: 'restart' });
expect(dependencyCalls[1].params).toEqual({ dependency: 'whisper', action: 'stop' });
expect(dependencyCalls[2].params).toEqual({ dependency: 'whisper', action: 'start' });
expect(dependencyCalls[3].params).toEqual({ dependency: 'whisper', action: 'update' });
expect(dependencyCalls[4].params).toEqual({ dependency: 'brave-search', action: 'restart' });
expect(state.dockerDependencies.find((entry) => entry.id === 'whisper')?.state).toBe('running');
expect(state.dockerDependencies.find((entry) => entry.id === 'brave-search')?.state).toBe('running');
});
});