EnergyVenom commited on
Commit
eee145b
·
verified ·
1 Parent(s): 6eb035f

Patchwise Agent Studio: Oracle AI Agent Studio cycles

Browse files
web/src/pages/FailureReview.tsx CHANGED
@@ -9,6 +9,7 @@ import { Can, ErrorAlert, Pill, Term } from '../components/common';
9
  import { reviewAnswer, type FailureChoice } from '../glossary';
10
  import { Presence } from './ScenarioReview';
11
  import './review.css';
 
12
 
13
  interface Draft { choice?: FailureChoice; note?: string; waiver?: string; owner?: string }
14
 
@@ -19,6 +20,14 @@ export function isDecided(f: Pick<Failure, 'ask'>, d: Draft | undefined): boolea
19
  return true;
20
  }
21
  const ANSWER_WORDS: Record<string, string> = { real_defect: 'real defect, ticket raised', not_defect: 'not a defect' };
 
 
 
 
 
 
 
 
22
 
23
  export function FailureCard({ f, draft, onChange, editable, quick = false }: { f: Failure; draft: Draft; onChange: (d: Draft) => void; editable: boolean; quick?: boolean }) {
24
  const { can } = useAuth();
@@ -81,6 +90,10 @@ export function FailureReview({ id, waiting }: { id: string; waiting: boolean })
81
  const list = q.data ?? [];
82
  const pending = list.filter((f) => f.pending);
83
  const open = pending.filter((f) => !isDecided(f, drafts[f.case_id])).length;
 
 
 
 
84
  const send = () => {
85
  if (open) return;
86
  const review = Object.fromEntries(pending.map((f) => {
@@ -102,7 +115,33 @@ export function FailureReview({ id, waiting }: { id: string; waiting: boolean })
102
  </Text>
103
  )}
104
  {list.length === 0 && <Text size="sm" c="dimmed">{q.isLoading ? 'Loading the failures…' : waiting ? 'Nothing is waiting for your decision.' : 'No failures in this test run.'}</Text>}
105
- {list.map((f) => <FailureCard key={f.case_id} f={f} quick={quick} editable={waiting} draft={drafts[f.case_id] ?? {}} onChange={(d) => setDrafts((s) => ({ ...s, [f.case_id]: d }))} />)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  {waiting && pending.length > 0 && (
107
  <>
108
  <ErrorAlert error={submit.error} />
 
9
  import { reviewAnswer, type FailureChoice } from '../glossary';
10
  import { Presence } from './ScenarioReview';
11
  import './review.css';
12
+ import './split.css';
13
 
14
  interface Draft { choice?: FailureChoice; note?: string; waiver?: string; owner?: string }
15
 
 
20
  return true;
21
  }
22
  const ANSWER_WORDS: Record<string, string> = { real_defect: 'real defect, ticket raised', not_defect: 'not a defect' };
23
+ const CHOICE_WORDS: Record<string, string> = { real_defect: 'real defect', not_defect: 'not a defect', expected_change: 'expected change' };
24
+
25
+ /** Where a failure stands, for the list: answered, decided in this review, or still waiting. */
26
+ function stateOf(f: Failure, d: Draft | undefined, waiting: boolean): { k: string; words: string } {
27
+ if (f.answer) return { k: 'pass', words: 'Answered' };
28
+ if (waiting && f.pending) return isDecided(f, d) ? { k: 'pass', words: `Decided: ${d?.choice ? CHOICE_WORDS[d.choice] ?? d.choice : `owner ${d?.owner?.trim()}`}` } : { k: 'wait', words: 'Needs your decision' };
29
+ return { k: f.outcome === 'flaky' ? 'flaky' : 'fail', words: f.outcome === 'flaky' ? 'Passed on retry' : 'Failed' };
30
+ }
31
 
32
  export function FailureCard({ f, draft, onChange, editable, quick = false }: { f: Failure; draft: Draft; onChange: (d: Draft) => void; editable: boolean; quick?: boolean }) {
33
  const { can } = useAuth();
 
90
  const list = q.data ?? [];
91
  const pending = list.filter((f) => f.pending);
92
  const open = pending.filter((f) => !isDecided(f, drafts[f.case_id])).length;
93
+ const [pick, setPick] = useState<string | null>(null);
94
+ // the chosen failure, else the first one still waiting for a decision
95
+ const cur = list.find((f) => f.case_id === pick) ?? pending.find((f) => !isDecided(f, drafts[f.case_id])) ?? list[0];
96
+ const at = cur ? list.indexOf(cur) : -1;
97
  const send = () => {
98
  if (open) return;
99
  const review = Object.fromEntries(pending.map((f) => {
 
115
  </Text>
116
  )}
117
  {list.length === 0 && <Text size="sm" c="dimmed">{q.isLoading ? 'Loading the failures…' : waiting ? 'Nothing is waiting for your decision.' : 'No failures in this test run.'}</Text>}
118
+ {cur && (
119
+ <div className="sp-split">
120
+ <nav className="sp-list" aria-label="Failures">
121
+ <div className="sp-items">
122
+ {list.map((f) => {
123
+ const st = stateOf(f, drafts[f.case_id], waiting);
124
+ return (
125
+ <button key={f.case_id} type="button" className="sp-item" data-k={st.k} aria-current={cur.case_id === f.case_id || undefined} onClick={() => setPick(f.case_id)}>
126
+ <span className="sp-dot" data-k={st.k} aria-hidden />
127
+ <span className="sp-it"><b>{f.title ?? f.case_id}</b><span className="sp-sub">{f.case_id}{f.priority_words ? ` · ${f.priority_words}` : ''} · {st.words}</span></span>
128
+ </button>
129
+ );
130
+ })}
131
+ </div>
132
+ </nav>
133
+ <section className="sp-detail sp-detail-plain" aria-label={`Failure ${cur.case_id}`}>
134
+ <FailureCard key={cur.case_id} f={cur} quick={quick} editable={waiting} draft={drafts[cur.case_id] ?? {}} onChange={(d) => { setPick(cur.case_id); setDrafts((s) => ({ ...s, [cur.case_id]: d })); }} />
135
+ {list.length > 1 && (
136
+ <Group justify="space-between" mt="sm">
137
+ <Button variant="default" size="xs" disabled={at === 0} onClick={() => setPick(list[at - 1].case_id)}>Previous failure</Button>
138
+ <Text size="xs" c="dimmed">{at + 1} of {list.length}</Text>
139
+ <Button variant="default" size="xs" disabled={at === list.length - 1} onClick={() => setPick(list[at + 1].case_id)}>Next failure</Button>
140
+ </Group>
141
+ )}
142
+ </section>
143
+ </div>
144
+ )}
145
  {waiting && pending.length > 0 && (
146
  <>
147
  <ErrorAlert error={submit.error} />
web/src/pages/ScenarioReview.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import { ActionIcon, Accordion, Alert, Button, Collapse, Group, Modal, SimpleGrid, Skeleton, Stack, Table, Text, Textarea, Tooltip, UnstyledButton } from '@mantine/core';
2
  import { IconChevronDown, IconChevronRight, IconCircleCheck, IconCircleX, IconCode, IconListNumbers, IconUser, IconWorldOff } from '@/icons';
3
  import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';
4
- import { useApproveCases, useCaseYaml, useGate, useRunScenarios } from '../api/hooks';
5
  import type { AiDraft, ApproveGate, DryRun, PendingCase, Scenario } from '../api/types';
6
  import { AiText, Can, Diff, ErrorAlert, Pill, Prio, Pre, Term } from '../components/common';
7
  import { FilterChips } from '../components/shell/FilterChips';
@@ -10,6 +10,7 @@ import { PRIORITY_WORDS } from '../glossary';
10
  import { shortWhen } from '../runName';
11
  import { CoworkerAvatar } from '../components/CoworkerAvatar';
12
  import { coworkerForNode } from '../coworkers';
 
13
  import './review.css';
14
 
15
  /** The full time of a timestamp in UTC, for a tooltip beside a time shown in the viewer's zone. */
@@ -341,6 +342,7 @@ const uniqueById = <T extends { id: string }>(list: T[]): T[] => { const seen =
341
  export function ScenarioReview({ id, waiting }: { id: string; waiting: boolean }) {
342
  const gate = useGate(id, waiting);
343
  const sc = useRunScenarios(id);
 
344
  const approve = useApproveCases(id);
345
  const g = waiting && gate.data?.gate === 'approve_cases' ? (gate.data as ApproveGate) : null;
346
  const pending = useMemo(() => new Map((g?.pending ?? []).map((p) => [p.id, p])), [g]);
@@ -471,9 +473,9 @@ export function ScenarioReview({ id, waiting }: { id: string; waiting: boolean }
471
  </div>
472
  )}
473
  {others.length > 0 && (
474
- <section aria-label="scenarios in this test run" className="pw-card rv-section">
475
  <h2 className="rv-h">Scenarios in this test run ({others.length}){sc.data?.deferred?.length ? ` · ${sc.data.deferred.length} not in scope` : ''}</h2>
476
- <StepGroups list={others} kind="run" />
477
  </section>
478
  )}
479
  </Stack>
 
1
  import { ActionIcon, Accordion, Alert, Button, Collapse, Group, Modal, SimpleGrid, Skeleton, Stack, Table, Text, Textarea, Tooltip, UnstyledButton } from '@mantine/core';
2
  import { IconChevronDown, IconChevronRight, IconCircleCheck, IconCircleX, IconCode, IconListNumbers, IconUser, IconWorldOff } from '@/icons';
3
  import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';
4
+ import { useApproveCases, useCaseYaml, useGate, useRun, useRunScenarios } from '../api/hooks';
5
  import type { AiDraft, ApproveGate, DryRun, PendingCase, Scenario } from '../api/types';
6
  import { AiText, Can, Diff, ErrorAlert, Pill, Prio, Pre, Term } from '../components/common';
7
  import { FilterChips } from '../components/shell/FilterChips';
 
10
  import { shortWhen } from '../runName';
11
  import { CoworkerAvatar } from '../components/CoworkerAvatar';
12
  import { coworkerForNode } from '../coworkers';
13
+ import { ScenarioSplit } from './ScenarioSplit';
14
  import './review.css';
15
 
16
  /** The full time of a timestamp in UTC, for a tooltip beside a time shown in the viewer's zone. */
 
342
  export function ScenarioReview({ id, waiting }: { id: string; waiting: boolean }) {
343
  const gate = useGate(id, waiting);
344
  const sc = useRunScenarios(id);
345
+ const browserRun = (useRun(id).data?.playwright_mode ?? 'stub') !== 'stub';
346
  const approve = useApproveCases(id);
347
  const g = waiting && gate.data?.gate === 'approve_cases' ? (gate.data as ApproveGate) : null;
348
  const pending = useMemo(() => new Map((g?.pending ?? []).map((p) => [p.id, p])), [g]);
 
473
  </div>
474
  )}
475
  {others.length > 0 && (
476
+ <section aria-label="scenarios in this test run" className="rv-section">
477
  <h2 className="rv-h">Scenarios in this test run ({others.length}){sc.data?.deferred?.length ? ` · ${sc.data.deferred.length} not in scope` : ''}</h2>
478
+ <ScenarioSplit list={others} screens={browserRun} Body={ScenarioBody} />
479
  </section>
480
  )}
481
  </Stack>
web/src/pages/ScenarioSplit.tsx ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { TextInput } from '@mantine/core';
2
+ import { IconListCheck, IconSearch } from '@/icons';
3
+ import { useMemo, useState, type ComponentType } from 'react';
4
+ import type { Scenario } from '../api/types';
5
+ import { useSidePanelOptional } from '../components/shell/SidePanel';
6
+ import './split.css';
7
+
8
+ type Kind = 'fail' | 'flaky' | 'pass' | 'todo';
9
+ const kindOf = (s: Scenario): Kind => (s.outcome === 'failed' ? 'fail' : s.outcome === 'flaky' ? 'flaky' : s.outcome === 'passed' ? 'pass' : 'todo');
10
+ const WORDS: Record<Kind, string> = { fail: 'Failed', flaky: 'Passed on retry', pass: 'Passed', todo: 'Not tested' };
11
+ const FILTERS: { value: 'all' | Kind; label: string }[] = [
12
+ { value: 'all', label: 'All' }, { value: 'fail', label: 'Failed' }, { value: 'flaky', label: 'On retry' }, { value: 'pass', label: 'Passed' }, { value: 'todo', label: 'Not tested' },
13
+ ];
14
+
15
+ /** The scenarios of a run as a split workspace: a searchable list grouped by process step on the left, the chosen
16
+ * scenario on the right (its steps, roles and test data, drawn by `Body`). Failed scenarios come first in each step. */
17
+ export function ScenarioSplit({ list, screens, Body }: { list: Scenario[]; screens: boolean; Body: ComponentType<{ s: Scenario }> }) {
18
+ const panel = useSidePanelOptional();
19
+ const [q, setQ] = useState('');
20
+ const [filter, setFilter] = useState<'all' | Kind>('all');
21
+ const [pick, setPick] = useState<string | null>(null);
22
+ const count = (k: Kind) => list.filter((s) => kindOf(s) === k).length;
23
+ const shown = useMemo(() => {
24
+ const t = q.trim().toLowerCase();
25
+ const order: Record<Kind, number> = { fail: 0, flaky: 1, todo: 2, pass: 3 };
26
+ return list.filter((s) => (filter === 'all' || kindOf(s) === filter) && (!t || s.id.toLowerCase().includes(t) || s.title.toLowerCase().includes(t)))
27
+ .sort((a, b) => order[kindOf(a)] - order[kindOf(b)]);
28
+ }, [list, q, filter]);
29
+ const groups = useMemo(() => {
30
+ const m = new Map<string, Scenario[]>();
31
+ for (const s of shown) { const k = s.step ?? s.process ?? 'Other'; m.set(k, [...(m.get(k) ?? []), s]); }
32
+ return [...m.entries()];
33
+ }, [shown]);
34
+ const cur = list.find((s) => s.id === pick) ?? shown[0] ?? null;
35
+
36
+ return (
37
+ <div className="sp-split">
38
+ <nav className="sp-list" aria-label="Scenarios">
39
+ <TextInput size="sm" placeholder="Title or ID" aria-label="Find a scenario" leftSection={<IconSearch size={14} />} value={q} onChange={(e) => setQ(e.currentTarget.value)} />
40
+ <div className="sp-chips" role="group" aria-label="Show scenarios">
41
+ {FILTERS.filter((f) => f.value === 'all' || count(f.value) > 0).map((f) => (
42
+ <button key={f.value} type="button" className="sp-chip" data-k={f.value} aria-pressed={filter === f.value} onClick={() => setFilter(f.value)}>
43
+ {f.label} <span className="fpt-num">{f.value === 'all' ? list.length : count(f.value)}</span>
44
+ </button>
45
+ ))}
46
+ </div>
47
+ <div className="sp-items">
48
+ {groups.length === 0 && <p className="sp-none">No scenario matches.</p>}
49
+ {groups.map(([step, items]) => (
50
+ <div key={step} className="sp-group">
51
+ <h3 className="sp-gh">{step}</h3>
52
+ {items.map((s) => {
53
+ const k = kindOf(s);
54
+ return (
55
+ <button key={s.id} type="button" className="sp-item" data-k={k} aria-current={cur?.id === s.id || undefined} onClick={() => setPick(s.id)}>
56
+ <span className="sp-dot" data-k={k} aria-hidden />
57
+ <span className="sp-it"><b>{s.title}</b><span className="sp-sub">{s.id}{s.priority_words ? ` · ${s.priority_words}` : ''} · {WORDS[k]}</span></span>
58
+ </button>
59
+ );
60
+ })}
61
+ </div>
62
+ ))}
63
+ </div>
64
+ </nav>
65
+
66
+ <section className="sp-detail" aria-label={cur ? `Scenario ${cur.id}` : 'Scenario'}>
67
+ {!cur ? <p className="sp-none">Pick a scenario on the left.</p> : (
68
+ <>
69
+ <header className="sp-dh">
70
+ <div className="sp-minw0">
71
+ <span className="sp-kicker">{[cur.id, cur.priority_words, cur.step ?? cur.process].filter(Boolean).join(' · ')}</span>
72
+ <h2 className="sp-title">{cur.title}</h2>
73
+ </div>
74
+ <span className="sp-pill" data-k={kindOf(cur)}>{WORDS[kindOf(cur)]}</span>
75
+ </header>
76
+ {panel && (
77
+ <div className="sp-actions">
78
+ <button type="button" className="fpt-textlink" onClick={() => panel.show('steps', { scenario: cur.id })}><IconListCheck size={14} aria-hidden /> Steps in the side panel</button>
79
+ {screens && kindOf(cur) !== 'todo' && <button type="button" className="fpt-textlink" onClick={() => panel.show('screens', { scenario: cur.id })}>See the screens</button>}
80
+ </div>
81
+ )}
82
+ <div className="sp-body"><Body s={cur} /></div>
83
+ </>
84
+ )}
85
+ </section>
86
+ </div>
87
+ );
88
+ }
web/src/pages/fixes.test.tsx CHANGED
@@ -40,6 +40,7 @@ describe('failure review: every pending failure needs a decision', () => {
40
  expect(screen.getByTestId('review-open')).toHaveTextContent('2 not decided yet');
41
  fireEvent.click(screen.getByRole('radio', { name: /Not a defect/ }));
42
  await waitFor(() => expect(screen.getByTestId('review-open')).toHaveTextContent('1 not decided yet'));
 
43
  const owner = screen.getByRole('textbox', { name: /Who owns this unstable scenario/ });
44
  fireEvent.change(owner, { target: { value: ' ' } });
45
  expect(submit).toBeDisabled();
 
40
  expect(screen.getByTestId('review-open')).toHaveTextContent('2 not decided yet');
41
  fireEvent.click(screen.getByRole('radio', { name: /Not a defect/ }));
42
  await waitFor(() => expect(screen.getByTestId('review-open')).toHaveTextContent('1 not decided yet'));
43
+ fireEvent.click(screen.getByRole('button', { name: /Scenario B-2/ })); // the split view shows one failure at a time
44
  const owner = screen.getByRole('textbox', { name: /Who owns this unstable scenario/ });
45
  fireEvent.change(owner, { target: { value: ' ' } });
46
  expect(submit).toBeDisabled();
web/src/pages/split.css ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* The split workspace (ScenarioSplit.tsx, FailureReview.tsx): a list on the left, the chosen item on the right. */
2
+
3
+ .sp-split { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
4
+ .sp-list { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; max-height: calc(100vh - 200px); padding: 12px;
5
+ border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--sep); }
6
+ .sp-items { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
7
+ .sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
8
+ .sp-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--sep-strong); border-radius: 999px; background: transparent;
9
+ color: var(--label-2); font: 600 12px var(--font); cursor: pointer; }
10
+ .sp-chip:hover { color: var(--label); background: var(--fill); }
11
+ .sp-chip[aria-pressed='true'] { background: var(--label); border-color: var(--label); color: var(--bg); }
12
+ .sp-chip:focus-visible, .sp-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
13
+ .sp-gh { margin: 10px 6px 4px; font: 600 11px var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--label-3); }
14
+ .sp-group:first-child .sp-gh { margin-top: 2px; }
15
+ .sp-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 11px; background: transparent;
16
+ color: var(--label); text-align: left; font: 500 13px/18px var(--font); cursor: pointer; }
17
+ .sp-item:hover { background: var(--fill); }
18
+ .sp-item[aria-current='true'] { background: var(--bg); border-color: var(--ember); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ember) 12%, transparent); }
19
+ .sp-it { display: flex; flex-direction: column; min-width: 0; }
20
+ .sp-it b { font-weight: 650; }
21
+ .sp-sub { font-size: 12px; color: var(--label-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
22
+ .sp-dot { flex: none; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--fill-3); }
23
+ .sp-dot[data-k='pass'] { background: var(--green); }
24
+ .sp-dot[data-k='fail'] { background: var(--red); }
25
+ .sp-dot[data-k='flaky'], .sp-dot[data-k='wait'] { background: var(--orange); }
26
+ .sp-dot[data-k='wait'] { box-shadow: 0 0 0 4px color-mix(in srgb, var(--orange) 22%, transparent); }
27
+ .sp-none { margin: 8px 6px; font-size: 13px; color: var(--label-3); }
28
+
29
+ .sp-detail { min-width: 0; padding: 22px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--sep); }
30
+ .sp-detail-plain { padding: 0; background: transparent; border: 0; }
31
+ .sp-dh { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
32
+ .sp-minw0 { min-width: 0; }
33
+ .sp-kicker { font: 500 12px var(--mono); color: var(--label-3); }
34
+ .sp-title { margin: 4px 0 0; font: 700 24px/30px var(--font-display); letter-spacing: -0.01em; color: var(--label); }
35
+ .sp-pill { padding: 4px 12px; border-radius: 999px; background: var(--fill-2); color: var(--label-2); font: 700 12px/18px var(--font); }
36
+ .sp-pill[data-k='pass'] { background: var(--green-soft); color: var(--green); }
37
+ .sp-pill[data-k='fail'] { background: var(--red-soft); color: var(--red); }
38
+ .sp-pill[data-k='flaky'] { background: var(--orange-soft); color: var(--orange); }
39
+ .sp-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
40
+ .sp-actions .fpt-textlink { display: inline-flex; align-items: center; gap: 6px; }
41
+ .sp-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--sep); }
42
+
43
+ @media (max-width: 900px) {
44
+ .sp-split { grid-template-columns: minmax(0, 1fr); }
45
+ .sp-list { position: static; max-height: 320px; }
46
+ }