Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion frontend/src/v2/__tests__/V2DiscordCallback.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,23 @@ describe('V2DiscordCallback (d215 s-handoff)', () => {
expect(screen.queryByRole('combobox')).toBeNull();
act(() => { jest.advanceTimersByTime(2000); });
expect(screen.getByText('at /v2/pods/p1')).toBeInTheDocument();
expect(axios.get).not.toHaveBeenCalledWith('/api/pods/p1', expect.anything());
});

test('an agent-ensemble pod returns to its kept room, where its controls live', async () => {
jest.useFakeTimers();
localStorage.setItem('token', 'jwt');
axios.get.mockImplementation((url) => (url === '/api/discord/channels/112233445566778899'
? Promise.resolve({ data: [{ id: '112233445566778801', name: 'general' }] })
: Promise.resolve({ data: { type: 'agent-ensemble' } })));
axios.post.mockResolvedValue({ data: {} });
renderAt('/discord/success?pod_id=p1&guild_id=112233445566778899&server_name=S');
const select = await screen.findByRole('combobox', { name: 'Channel' });
await screen.findByRole('option', { name: '#general' });
fireEvent.change(select, { target: { value: '112233445566778801' } });
await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Connect' })); });
await waitFor(() => expect(screen.getByRole('status')).toBeInTheDocument());
act(() => { jest.advanceTimersByTime(2000); });
expect(screen.getByText('at /v2/pods/agent-ensemble/p1')).toBeInTheDocument();
});

test('a failed channel fetch and a failed create each land in the alert row', async () => {
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/v2/components/V2DiscordCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@ const V2DiscordCallback: React.FC<V2DiscordCallbackProps> = ({ type = 'callback'

setSuccess(t('auth.discordHandoff.created'));

// The v2 pod view takes any pod type, so the return no longer reads the pod first.
setTimeout(() => navigate(`/v2/pods/${encodeURIComponent(podId)}`), 2000);
// Every pod returns to the v2 pod view, except agent-ensemble: its controls
// live only in the room kept at /v2/pods/agent-ensemble/:id.
let back = `/v2/pods/${encodeURIComponent(podId)}`;
try {
const podResponse = await axios.get<{ type?: string }>(`/api/pods/${podId}`, {
headers: { Authorization: `Bearer ${token}` },
});
if (podResponse.data.type === 'agent-ensemble') back = `/v2/pods/agent-ensemble/${encodeURIComponent(podId)}`;
} catch (podError) {
console.error('Error fetching pod info, returning to the pod view:', podError);
}
setTimeout(() => navigate(back), 2000);
} catch (err: unknown) {
console.error('Error creating integration:', err);
const e = err as { response?: { data?: { message?: string } } };
Expand Down
Loading