Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(fullview): browse the narration transcript beside the guide

davbio431fd3a03a33
diff --git a/src/stores/fullview.ts b/src/stores/fullview.ts
index 76c35d0..219f4cd 100644
--- a/src/stores/fullview.ts
+++ b/src/stores/fullview.ts
@@ -41,6 +41,10 @@ interface FullviewStore {
setHistoryOpen: (open: boolean) => void;
historyRefreshKey: number;
bumpHistoryRefresh: () => void;
+ transcriptOpen: boolean;
+ setTranscriptOpen: (open: boolean) => void;
+ hasTranscript: boolean;
+ setHasTranscript: (has: boolean) => void;
}
function flushFocusedField() {
@@ -72,7 +76,14 @@ export const useFullviewStore = create<FullviewStore>((set) => ({
set((s) =>
s.guideExportData?.guideId === guideExportData?.guideId
? { guideExportData }
- : { guideExportData, editing: false, historyOpen: false, historyRefreshKey: 0 },
+ : {
+ guideExportData,
+ editing: false,
+ historyOpen: false,
+ historyRefreshKey: 0,
+ transcriptOpen: false,
+ hasTranscript: false,
+ },
),
scrollToStepId: null,
scrollToStep: (stepId) => {
@@ -90,10 +101,17 @@ export const useFullviewStore = create<FullviewStore>((set) => ({
historyOpen: false,
setHistoryOpen: (historyOpen) => {
if (historyOpen) flushFocusedField();
- set({ historyOpen });
+ set(historyOpen ? { historyOpen, transcriptOpen: false } : { historyOpen });
},
historyRefreshKey: 0,
bumpHistoryRefresh: () => set((s) => ({ historyRefreshKey: s.historyRefreshKey + 1 })),
+ transcriptOpen: false,
+ setTranscriptOpen: (transcriptOpen) => {
+ if (transcriptOpen) flushFocusedField();
+ set(transcriptOpen ? { transcriptOpen, historyOpen: false } : { transcriptOpen });
+ },
+ hasTranscript: false,
+ setHasTranscript: (hasTranscript) => set({ hasTranscript }),
}));
export function useFullview<T>(selector: (s: FullviewStore) => T): T {
diff --git a/src/ui/fullview/App.tsx b/src/ui/fullview/App.tsx
index 1753066..cdb4b77 100644
--- a/src/ui/fullview/App.tsx
+++ b/src/ui/fullview/App.tsx
@@ -11,9 +11,10 @@ import TopNav from './TopNav';
export default function FullViewApp() {
const route = useRoute();
- const { toggleSearch, historyOpen } = useFullview((s) => ({
+ const { toggleSearch, historyOpen, transcriptOpen } = useFullview((s) => ({
toggleSearch: s.toggleSearch,
historyOpen: s.historyOpen,
+ transcriptOpen: s.transcriptOpen,
}));
useEffect(() => {
@@ -42,7 +43,7 @@ export default function FullViewApp() {
{route.page === 'guide' && (
<main className="flex-1 py-10 px-6">
- <div className={`mx-auto ${historyOpen ? 'max-w-[1032px]' : 'max-w-[720px]'}`}>
+ <div className={`mx-auto ${historyOpen || transcriptOpen ? 'max-w-[1032px]' : 'max-w-[720px]'}`}>
<GuideContent guideId={route.guideId} initialStepId={route.stepId} initialTool={route.tool} />
</div>
</main>
diff --git a/src/ui/fullview/GuideContent.tsx b/src/ui/fullview/GuideContent.tsx
index 0632ce4..d4ec6d7 100644
--- a/src/ui/fullview/GuideContent.tsx
+++ b/src/ui/fullview/GuideContent.tsx
@@ -8,6 +8,7 @@ import {
deleteStep,
getGuide,
getScreenshotsForSteps,
+ hasTranscript,
onGuidesChanged,
updateGuideDescription,
updateGuideTitle,
@@ -28,6 +29,7 @@ import FaviconImg from '@/ui/shared/FaviconImg';
import { guideDescriptionErrorMessage } from '@/ui/shared/guide-description-error';
import Toast from '@/ui/shared/Toast';
import GuideStepList from './components/GuideStepList';
+import TranscriptPanel from './components/TranscriptPanel';
import VersionHistoryPanel from './components/VersionHistoryPanel';
interface GuideContentProps {
@@ -74,6 +76,9 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
historyOpen,
setHistoryOpen,
historyRefreshKey,
+ transcriptOpen,
+ setTranscriptOpen,
+ setHasTranscript,
} = useFullview((s) => ({
setGuideTitle: s.setGuideTitle,
setGuideStepCount: s.setGuideStepCount,
@@ -84,6 +89,9 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
historyOpen: s.historyOpen,
setHistoryOpen: s.setHistoryOpen,
historyRefreshKey: s.historyRefreshKey,
+ transcriptOpen: s.transcriptOpen,
+ setTranscriptOpen: s.setTranscriptOpen,
+ setHasTranscript: s.setHasTranscript,
}));
const [data, setData] = useState<GuideData | null>(null);
@@ -98,6 +106,7 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
const [generating, setGenerating] = useState(false);
const [hasApiKey, setHasApiKey] = useState(false);
const [descriptionError, setDescriptionError] = useState<string | null>(null);
+ const [dataVersion, setDataVersion] = useState(0);
const titleRef = useRef('');
const appliedInitialRef = useRef(false);
const editingDescriptionRef = useRef(false);
@@ -123,8 +132,12 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
setGuideTitle(newTitle);
setGuideStepCount(actionSteps(result.steps).length);
}
+ hasTranscript(guideId)
+ .then(setHasTranscript)
+ .catch((err) => logger.error(' Transcript lookup failed', err));
+ setDataVersion((version) => version + 1);
setLoading(false);
- }, [guideId, setGuideTitle, setGuideStepCount]);
+ }, [guideId, setGuideTitle, setGuideStepCount, setHasTranscript]);
useEffect(() => {
loadGuide();
@@ -290,6 +303,7 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
);
if (!data) return <p className="text-sm py-12 text-center text-purple">{i18n.t('fullview_guideNotFound')}</p>;
+ const sidePanelOpen = historyOpen || transcriptOpen;
const previewView = preview && previewData?.snapshotId === preview.id ? previewData : null;
const viewSteps = previewView ? previewView.steps : data.steps;
const viewScreenshots = previewView ? previewView.screenshots : data.screenshots;
@@ -312,8 +326,8 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
/>
)}
- <div className={historyOpen ? 'flex items-start gap-6' : ''}>
- <div className={historyOpen ? 'flex-1 min-w-0' : ''}>
+ <div className={sidePanelOpen ? 'flex items-start gap-6' : ''}>
+ <div className={sidePanelOpen ? 'flex-1 min-w-0' : ''}>
{preview && (
<div className="flex items-center gap-2 rounded-lg bg-secondary border border-border px-4 py-3 mb-4">
<History size={15} className="text-accent shrink-0" />
@@ -494,6 +508,18 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
/>
</div>
+ {transcriptOpen && (
+ <TranscriptPanel
+ guideId={guideId}
+ guideTitle={data.guide.title}
+ steps={data.steps}
+ readOnly={!editing || preview !== null}
+ refreshKey={dataVersion}
+ onClose={() => setTranscriptOpen(false)}
+ onChanged={loadGuide}
+ />
+ )}
+
{historyOpen && (
<VersionHistoryPanel
guideId={guideId}
diff --git a/src/ui/fullview/TopNav.tsx b/src/ui/fullview/TopNav.tsx
index 3025f31..4b0c48f 100644
--- a/src/ui/fullview/TopNav.tsx
+++ b/src/ui/fullview/TopNav.tsx
@@ -1,4 +1,15 @@
-import { Check, ChevronRight, Download, FileText, History, Pencil, Search, Star, Trash2 } from 'lucide-react';
+import {
+ Check,
+ ChevronRight,
+ Download,
+ FileText,
+ History,
+ MessageSquareQuote,
+ Pencil,
+ Search,
+ Star,
+ Trash2,
+} from 'lucide-react';
import { useState } from 'react';
import { i18n } from '#imports';
import { createSnapshot } from '@/core/guides/service';
@@ -34,6 +45,9 @@ export default function TopNav({ route }: TopNavProps) {
historyOpen,
setHistoryOpen,
bumpHistoryRefresh,
+ transcriptOpen,
+ setTranscriptOpen,
+ hasTranscript,
} = useFullview((s) => ({
counts: s.counts,
guideTitle: s.guideTitle,
@@ -45,6 +59,9 @@ export default function TopNav({ route }: TopNavProps) {
historyOpen: s.historyOpen,
setHistoryOpen: s.setHistoryOpen,
bumpHistoryRefresh: s.bumpHistoryRefresh,
+ transcriptOpen: s.transcriptOpen,
+ setTranscriptOpen: s.setTranscriptOpen,
+ hasTranscript: s.hasTranscript,
}));
const [exportOpen, setExportOpen] = useState(false);
@@ -140,6 +157,17 @@ export default function TopNav({ route }: TopNavProps) {
<History size={14} />
{i18n.t('editor.versionHistory')}
</Button>
+ {hasTranscript && (
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={() => setTranscriptOpen(!transcriptOpen)}
+ className={NAV_CONTROL}
+ >
+ <MessageSquareQuote size={14} />
+ {i18n.t('transcript.title')}
+ </Button>
+ )}
{!editing && (
<Button size="sm" onClick={() => setExportOpen(true)} className="h-8 rounded-lg">
<Download size={14} />
diff --git a/src/ui/fullview/components/TranscriptPanel.tsx b/src/ui/fullview/components/TranscriptPanel.tsx
new file mode 100644
index 0000000..51160e4
--- /dev/null
+++ b/src/ui/fullview/components/TranscriptPanel.tsx
@@ -0,0 +1,258 @@
+import { Check, Copy, Download, Plus, Trash2, X } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
+import { i18n } from '#imports';
+import { downloadText, safeFilename } from '@/core/export/download';
+import { stepNumbers } from '@/core/guides/blocks';
+import {
+ appendToStepDescription,
+ attachTranscriptLine,
+ deleteTranscripts,
+ getTranscripts,
+} from '@/core/guides/service';
+import {
+ countUnused,
+ formatOffset,
+ mergeTranscripts,
+ nearestStepId,
+ type TimelineLine,
+ transcriptToText,
+ withLiveSteps,
+} from '@/core/guides/transcript';
+import type { Step } from '@/core/guides/types';
+import { logger } from '@/lib/logger';
+import { useFullview } from '@/stores/fullview';
+import { Button } from '@/ui/components/ui/button';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/ui/components/ui/tooltip';
+import ConfirmDialog from '@/ui/shared/ConfirmDialog';
+
+interface TranscriptPanelProps {
+ guideId: string;
+ guideTitle: string;
+ steps: Step[];
+ readOnly?: boolean;
+ refreshKey?: number;
+ onClose: () => void;
+ onChanged?: () => void;
+}
+
+function pill(active: boolean): string {
+ return `px-2 py-0.5 rounded-full text-[10px] font-semibold border ${
+ active
+ ? 'bg-secondary border-border text-foreground'
+ : 'border-transparent text-muted-foreground hover:text-foreground'
+ }`;
+}
+
+export default function TranscriptPanel({
+ guideId,
+ guideTitle,
+ steps,
+ readOnly,
+ refreshKey,
+ onClose,
+ onChanged,
+}: TranscriptPanelProps) {
+ const scrollToStep = useFullview((s) => s.scrollToStep);
+ const [lines, setLines] = useState<TimelineLine[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState<string | null>(null);
+ const [unusedOnly, setUnusedOnly] = useState(false);
+ const [copied, setCopied] = useState(false);
+ const [confirmDelete, setConfirmDelete] = useState(false);
+ const refreshRef = useRef(refreshKey);
+
+ const load = useCallback(async () => {
+ try {
+ setLines(mergeTranscripts(await getTranscripts(guideId)));
+ } catch (err) {
+ logger.error(' Transcript could not be read', err);
+ setError(i18n.t('transcript.loadError'));
+ } finally {
+ setLoading(false);
+ }
+ }, [guideId]);
+
+ useEffect(() => {
+ const silent = refreshRef.current === refreshKey;
+ refreshRef.current = refreshKey;
+ if (!silent) {
+ setLoading(true);
+ setError(null);
+ }
+ void load();
+ }, [load, refreshKey]);
+
+ const numbers = useMemo(() => stepNumbers(steps), [steps]);
+
+ const timeline = useMemo(() => withLiveSteps(lines, steps), [lines, steps]);
+
+ const unused = countUnused(timeline);
+ const shown = timeline.map((line, index) => ({ line, index })).filter(({ line }) => !unusedOnly || !line.stepId);
+
+ const handleCopyAll = async () => {
+ try {
+ await navigator.clipboard.writeText(transcriptToText(timeline, numbers));
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ } catch (err) {
+ logger.error(' Transcript could not be copied', err);
+ }
+ };
+
+ const handleDownload = () => {
+ downloadText(transcriptToText(timeline, numbers), safeFilename(`${guideTitle} transcript`, 'txt'), 'text/plain');
+ };
+
+ const handleDelete = async () => {
+ setConfirmDelete(false);
+ await deleteTranscripts(guideId);
+ setLines([]);
+ onChanged?.();
+ };
+
+ const targetFor = (line: TimelineLine, index: number): string | null => line.stepId ?? nearestStepId(timeline, index);
+
+ const handleAddToStep = async (line: TimelineLine, index: number) => {
+ const targetId = targetFor(line, index);
+ if (!targetId) return;
+ if (!(await appendToStepDescription(targetId, line.text))) return;
+ await attachTranscriptLine(line.rowId, line.lineIndex, targetId);
+ await load();
+ onChanged?.();
+ };
+
+ return (
+ <aside className="w-72 shrink-0 border-l border-border pl-4 flex flex-col gap-1">
+ <div className="flex items-center gap-2 h-10">
+ <button
+ type="button"
+ onClick={onClose}
+ aria-label={i18n.t('common.close')}
+ className="p-1 text-muted-foreground hover:text-foreground"
+ >
+ <X size={14} />
+ </button>
+ <span className="text-[13px] font-semibold text-foreground">{i18n.t('transcript.title')}</span>
+ </div>
+
+ {error && (
+ <p role="alert" className="text-[11px] text-destructive py-2">
+ {error}
+ </p>
+ )}
+
+ {loading ? (
+ <p className="text-[11px] text-muted-foreground py-2">{i18n.t('common.loading')}</p>
+ ) : lines.length === 0 ? (
+ <p className="text-[11px] text-muted-foreground py-2">{i18n.t('transcript.empty')}</p>
+ ) : (
+ <>
+ <div className="flex items-center gap-1 pb-1">
+ <button
+ type="button"
+ aria-pressed={!unusedOnly}
+ className={pill(!unusedOnly)}
+ onClick={() => setUnusedOnly(false)}
+ >
+ {i18n.t('transcript.filterAll', [String(lines.length)])}
+ </button>
+ <button
+ type="button"
+ aria-pressed={unusedOnly}
+ className={pill(unusedOnly)}
+ onClick={() => setUnusedOnly(true)}
+ >
+ {i18n.t('transcript.filterUnused', [String(unused)])}
+ </button>
+ </div>
+
+ <p className="text-[10px] leading-snug text-muted-foreground pb-1">{i18n.t('transcript.privacyNote')}</p>
+
+ {readOnly && unused > 0 && (
+ <p className="text-[10px] leading-snug text-accent pb-1">{i18n.t('transcript.readOnlyHint')}</p>
+ )}
+
+ <ul className="flex flex-col gap-2 overflow-y-auto pr-1">
+ {shown.map(({ line, index }) => {
+ const number = line.stepId ? numbers.get(line.stepId) : undefined;
+ const targetId = targetFor(line, index);
+ const suggestion = targetId ? numbers.get(targetId) : undefined;
+ return (
+ <li key={`${line.atMs}-${index}`} className="flex flex-col gap-0.5">
+ <div className="flex items-center gap-1.5">
+ <span className="text-[10px] font-semibold tabular-nums text-muted-foreground">
+ {formatOffset(line.offsetSeconds)}
+ </span>
+ {number ? (
+ <button
+ type="button"
+ onClick={() => line.stepId && scrollToStep(line.stepId)}
+ className="text-[9px] font-bold uppercase tracking-wide rounded px-1 py-[2px] bg-success/10 text-success"
+ >
+ {i18n.t('transcript.usedInStep', [String(number)])}
+ </button>
+ ) : (
+ <span className="text-[9px] font-bold uppercase tracking-wide rounded px-1 py-[2px] border border-border text-muted-foreground">
+ {line.rejectReason ? i18n.t('transcript.filteredOut') : i18n.t('transcript.notUsed')}
+ </span>
+ )}
+ {!readOnly && !number && suggestion && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ onClick={() => void handleAddToStep(line, index)}
+ aria-label={i18n.t('transcript.addToStep', [String(suggestion)])}
+ className="ml-auto p-0.5 rounded text-muted-foreground hover:text-accent"
+ >
+ <Plus size={12} />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent>{i18n.t('transcript.addToStep', [String(suggestion)])}</TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ <p className="text-[11px] leading-snug text-foreground">{line.text}</p>
+ </li>
+ );
+ })}
+ </ul>
+
+ <div className="flex items-center gap-1 pt-2 mt-auto">
+ <Button size="sm" variant="ghost" onClick={() => void handleCopyAll()} className="h-7 px-2 text-[11px]">
+ {copied ? <Check size={12} className="text-success" /> : <Copy size={12} />}
+ {i18n.t('transcript.copyAll')}
+ </Button>
+ <Button size="sm" variant="ghost" onClick={handleDownload} className="h-7 px-2 text-[11px]">
+ <Download size={12} />
+ {i18n.t('transcript.download')}
+ </Button>
+ {!readOnly && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ onClick={() => setConfirmDelete(true)}
+ aria-label={i18n.t('transcript.delete')}
+ className="ml-auto p-1 rounded-md text-muted-foreground hover:text-destructive"
+ >
+ <Trash2 size={13} />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent>{i18n.t('transcript.delete')}</TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ </>
+ )}
+
+ <ConfirmDialog
+ open={confirmDelete}
+ heading={i18n.t('transcript.confirmDelete')}
+ destructive
+ onConfirm={() => void handleDelete()}
+ onCancel={() => setConfirmDelete(false)}
+ />
+ </aside>
+ );
+}
diff --git a/src/ui/fullview/components/__tests__/transcript-panel.test.tsx b/src/ui/fullview/components/__tests__/transcript-panel.test.tsx
new file mode 100644
index 0000000..33e6a7e
--- /dev/null
+++ b/src/ui/fullview/components/__tests__/transcript-panel.test.tsx
@@ -0,0 +1,183 @@
+// @vitest-environment jsdom
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import type { GuideTranscript, Step } from '@/core/guides/types';
+import { TooltipProvider } from '@/ui/components/ui/tooltip';
+
+const getTranscripts = vi.fn();
+const appendToStepDescription = vi.fn();
+const attachTranscriptLine = vi.fn();
+const deleteTranscripts = vi.fn();
+
+vi.mock('@/core/guides/service', () => ({
+ getTranscripts: (...args: unknown[]) => getTranscripts(...args),
+ appendToStepDescription: (...args: unknown[]) => appendToStepDescription(...args),
+ attachTranscriptLine: (...args: unknown[]) => attachTranscriptLine(...args),
+ deleteTranscripts: (...args: unknown[]) => deleteTranscripts(...args),
+}));
+
+import TranscriptPanel from '../TranscriptPanel';
+
+const EPOCH = 1_700_000_000_000;
+
+function step(id: string, index: number): Step {
+ return {
+ id,
+ guideId: 'g1',
+ index,
+ description: 'Clicked something',
+ action: 'click',
+ url: 'https://a.test',
+ timestamp: 1,
+ };
+}
+
+function transcript(lines: Array<[number, string, string | null, string | null]>): GuideTranscript {
+ return {
+ id: 't1',
+ guideId: 'g1',
+ epochMs: EPOCH,
+ createdAt: 1,
+ lines: lines.map(([start, text, stepId, rejectReason]) => ({
+ start,
+ end: start + 1,
+ text,
+ stepId,
+ rejectReason,
+ })),
+ };
+}
+
+function renderPanel(rows: GuideTranscript[], steps: Step[], readOnly = false) {
+ getTranscripts.mockResolvedValue(rows);
+ return render(
+ <TooltipProvider>
+ <TranscriptPanel
+ guideId="g1"
+ guideTitle="Test Guide"
+ steps={steps}
+ readOnly={readOnly}
+ onClose={vi.fn()}
+ onChanged={vi.fn()}
+ />
+ </TooltipProvider>,
+ );
+}
+
+beforeEach(() => {
+ getTranscripts.mockReset();
+ appendToStepDescription.mockReset();
+ attachTranscriptLine.mockReset().mockResolvedValue(undefined);
+ deleteTranscripts.mockReset();
+});
+
+describe('TranscriptPanel', () => {
+ it('marks a line whose step was deleted as unused and offers it to a live step', async () => {
+ renderPanel(
+ [
+ transcript([
+ [1, 'first line', 's1', null],
+ [3, 'orphaned line', 'gone', null],
+ [5, 'third line', 's3', null],
+ ]),
+ ],
+ [step('s1', 0), step('s3', 1)],
+ );
+
+ await screen.findByText('orphaned line');
+ expect(screen.getByText('transcript.filterUnused[1]')).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'transcript.addToStep[2]' })).toBeTruthy();
+ });
+
+ it('appends an unused line to the step that follows it', async () => {
+ appendToStepDescription.mockResolvedValue('Clicked something and then some');
+ renderPanel(
+ [
+ transcript([
+ [1, 'click save', 's1', null],
+ [3, 'stray thought', null, null],
+ [5, 'now the dialog', 's3', null],
+ ]),
+ ],
+ [step('s1', 0), step('s3', 1)],
+ );
+
+ fireEvent.click(await screen.findByRole('button', { name: 'transcript.addToStep[2]' }));
+
+ await waitFor(() => expect(appendToStepDescription).toHaveBeenCalledWith('s3', 'stray thought'));
+ });
+
+ it('records the attribution, so reopening cannot append the same line twice', async () => {
+ appendToStepDescription.mockResolvedValue('Clicked something and then some');
+ const seeded = transcript([
+ [1, 'click save', 's1', null],
+ [3, 'stray thought', null, null],
+ [5, 'now the dialog', 's3', null],
+ ]);
+ const attached = {
+ ...seeded,
+ lines: seeded.lines.map((l, i) => (i === 1 ? { ...l, stepId: 's3' } : l)),
+ };
+ getTranscripts.mockResolvedValueOnce([seeded]).mockResolvedValue([attached]);
+
+ render(
+ <TooltipProvider>
+ <TranscriptPanel
+ guideId="g1"
+ guideTitle="Test Guide"
+ steps={[step('s1', 0), step('s3', 1)]}
+ onClose={vi.fn()}
+ onChanged={vi.fn()}
+ />
+ </TooltipProvider>,
+ );
+
+ fireEvent.click(await screen.findByRole('button', { name: 'transcript.addToStep[2]' }));
+
+ await waitFor(() => expect(attachTranscriptLine).toHaveBeenCalledWith(seeded.id, 1, 's3'));
+ await waitFor(() => expect(screen.queryByRole('button', { name: /transcript.addToStep/ })).toBeNull());
+ expect(appendToStepDescription).toHaveBeenCalledTimes(1);
+ });
+
+ it('keeps a filtered line visible with its own tag', async () => {
+ renderPanel([transcript([[1, 'Thanks for watching', null, 'blocklist:thanks for watching']])], [step('s1', 0)]);
+
+ await screen.findByText('Thanks for watching');
+ expect(screen.getByText('transcript.filteredOut')).toBeTruthy();
+ });
+
+ it('says so when nothing was narrated', async () => {
+ renderPanel([], [step('s1', 0)]);
+ expect(await screen.findByText('transcript.empty')).toBeTruthy();
+ });
+
+ it('does not offer the irreversible delete while the guide is read-only', async () => {
+ renderPanel([transcript([[1, 'a line', 's1', null]])], [step('s1', 0)], true);
+
+ await screen.findByText('a line');
+ expect(screen.queryByRole('button', { name: 'transcript.delete' })).toBeNull();
+ expect(screen.queryByRole('button', { name: /transcript.addToStep/ })).toBeNull();
+ });
+
+ it('says why there is no way to add a line while read-only', async () => {
+ renderPanel(
+ [
+ transcript([
+ [1, 'click save', 's1', null],
+ [3, 'stray thought', null, null],
+ ]),
+ ],
+ [step('s1', 0)],
+ true,
+ );
+
+ expect(await screen.findByText('transcript.readOnlyHint')).toBeTruthy();
+ });
+
+ it('stays quiet about editing when every line is already used', async () => {
+ renderPanel([transcript([[1, 'click save', 's1', null]])], [step('s1', 0)], true);
+
+ await screen.findByText('click save');
+ expect(screen.queryByText('transcript.readOnlyHint')).toBeNull();
+ });
+});