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
26 changes: 19 additions & 7 deletions apps/web/src/components/OneLoopStudio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
} from '@/lib/studio-workflow';
import { identityPackJson } from '@/lib/emit-video-pack';
import {
studioActionCard,
studioCanExport,
studioCanRetryTranscript,
studioDeployButtonLabel,
Expand Down Expand Up @@ -428,7 +429,7 @@
const started = await startVideoToActions(payload);
if (!started.ok || !started.runId) {
if (started.status === 401 || started.status === 403) {
window.location.href = `/login?callbackUrl=${encodeURIComponent(CANONICAL_STUDIO_PATH)}`;

Check warning on line 432 in apps/web/src/components/OneLoopStudio.tsx

View workflow job for this annotation

GitHub Actions / lint-frontend

Do not use `window.location.href` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: https://nextjs.org/docs/messages/no-location-assign-relative-destination

Check warning on line 432 in apps/web/src/components/OneLoopStudio.tsx

View workflow job for this annotation

GitHub Actions / build

Do not use `window.location.href` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: https://nextjs.org/docs/messages/no-location-assign-relative-destination
return;
}
setMessage(started.error || started.message || 'Could not start Act.');
Expand Down Expand Up @@ -540,7 +541,7 @@
try {
const started = await startStudioDeploy({ url: next });
if (started.status === 401 || started.status === 403) {
window.location.href = `/login?callbackUrl=${encodeURIComponent(CANONICAL_STUDIO_PATH)}`;

Check warning on line 544 in apps/web/src/components/OneLoopStudio.tsx

View workflow job for this annotation

GitHub Actions / lint-frontend

Do not use `window.location.href` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: https://nextjs.org/docs/messages/no-location-assign-relative-destination

Check warning on line 544 in apps/web/src/components/OneLoopStudio.tsx

View workflow job for this annotation

GitHub Actions / build

Do not use `window.location.href` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: https://nextjs.org/docs/messages/no-location-assign-relative-destination
return;
}
if (!started.ok || !started.runId) {
Expand Down Expand Up @@ -1067,13 +1068,24 @@
{workflowActions.actions.length === 0 && (
<li className="text-white/50">No tool results from this run.</li>
)}
{workflowActions.actions.map((action, i) => (
<li key={`${action.tool}-${i}`}>
<span className="font-medium">{action.tool}</span>
<span className="text-white/50"> — {action.status}</span>
{action.result && <div className="text-white/70">{action.result}</div>}
</li>
))}
{workflowActions.actions.map((action, i) => {
const card = studioActionCard(action);
return (
<li
key={`${action.tool}-${i}`}
data-testid="studio-action-card"
className="rounded-lg border border-white/10 bg-black/20 px-3 py-2"
>
<div className="flex flex-wrap items-center justify-between gap-2">
<span className="font-medium text-white">{card.title}</span>
<span className="font-mono text-[11px] uppercase tracking-[0.12em] text-[#e8b86d]">
{card.statusLabel}
</span>
</div>
<p className="mt-1 text-white/70">{card.detail}</p>
</li>
);
})}
</ul>
) : (
<p className="mt-3 text-sm text-white/60">
Expand Down
23 changes: 23 additions & 0 deletions apps/web/src/lib/__tests__/studio-pipeline-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import {
studioActionCard,
studioCanExport,
studioCanRetryTranscript,
studioDeployButtonLabel,
Expand Down Expand Up @@ -327,6 +328,28 @@ describe('studio-pipeline-status', () => {
expect(studio).not.toContain('>Deploy<');
});

it('renders review_action as a card with status, title, and detail', () => {
const review = studioActionCard({
tool: 'review_action',
status: 'proposed',
result: 'Review evidence',
});
expect(review.kind).toBe('review');
expect(review.title).toMatch(/review this result/i);
expect(review.statusLabel).toBe('Needs review');
expect(review.detail).toBe('Review evidence');

const tool = studioActionCard({ tool: 'persist_insight', status: 'completed' });
expect(tool.kind).toBe('tool');
expect(tool.title).toMatch(/persist insight/i);
expect(tool.statusLabel).toBe('Done');
expect(tool.detail).toMatch(/no detail/i);

const studio = readFileSync(join(process.cwd(), 'src/components/OneLoopStudio.tsx'), 'utf8');
expect(studio).toContain('studioActionCard');
expect(studio).toContain('data-testid="studio-action-card"');
});

it('returns a toast for export success and failure including filename', () => {
expect(studioExportFilename('AI Gold Rushes')).toBe('AI Gold Rushes.zip');
const pack = studioExportToastMessage({
Expand Down
37 changes: 37 additions & 0 deletions apps/web/src/lib/studio-pipeline-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,43 @@ export function studioExportFilename(projectName?: string | null): string {
return base.toLowerCase().endsWith('.zip') ? base : `${base}.zip`;
}

export function studioActionCard(action: {
tool: string;
status: string;
result?: string;
}): {
title: string;
statusLabel: string;
detail: string;
kind: 'review' | 'tool';
} {
const isReview = action.tool === 'review_action';
const statusLabel =
action.status === 'proposed'
? 'Needs review'
: action.status === 'completed'
? 'Done'
: action.status === 'failed'
? 'Failed'
: action.status;
const title = isReview
? 'Review this result'
: action.tool
.split('_')
.filter(Boolean)
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(' ');
const detail =
action.result?.trim() ||
(isReview ? 'Open the evidence on this page before you act.' : 'No detail from this tool.');
return {
title,
statusLabel,
detail,
kind: isReview ? 'review' : 'tool',
};
}

export function studioExportToastMessage(input: {
ok: boolean;
kind?: StudioExportToastKind;
Expand Down
Loading