Skip to content

Commit a533f3a

Browse files
Simon Dobaclaude
andcommitted
fix(web): key a handled reveal by file, not by request id alone
Review feedback, and a regression I introduced: each file surface counts its reveals from one, so after dismissing a reveal on one file the first line link to another file carried the same id, was taken for already handled, and never left the rendered view. Pair the id with the path again, the way the state it replaced did. Co-Authored-By: Claude Opus 5 <[email protected]>
1 parent dae51be commit a533f3a

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎apps/web/src/components/files/FilePreviewPanel.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,20 @@ export default function FilePreviewPanel({
685685
// Reading markdown rendered is a preference, not a property of one file. Keeping
686686
// it on the panel meant a thread switch dropped it and forced source back.
687687
const [renderMarkdownPreferred, setRenderMarkdownPreferred] = useState(initialRenderMarkdown);
688-
const [revealHandledRequestId, setRevealHandledRequestId] = useState<number | null>(null);
688+
// Paired with the path on purpose: each file surface counts its reveals from
689+
// one, so a bare id would let a dismissed reveal on one file swallow the first
690+
// reveal on the next.
691+
const [handledReveal, setHandledReveal] = useState<{ path: string; requestId: number } | null>(
692+
null,
693+
);
689694
const breadcrumbRef = useRef<HTMLDivElement>(null);
690695
const isMarkdown = relativePath ? isMarkdownPreviewFile(relativePath) : false;
691696
// A reveal still wins over the preference: the line only exists in the source.
692697
const renderMarkdown =
693698
isMarkdown &&
694699
renderMarkdownPreferred &&
695-
(revealLine === null || revealHandledRequestId === revealRequestId);
700+
(revealLine === null ||
701+
(handledReveal?.path === relativePath && handledReveal.requestId === revealRequestId));
696702
const canOpenInBrowser =
697703
relativePath !== null && isPreviewSupportedInRuntime() && isBrowserPreviewFile(relativePath);
698704
const absolutePath = relativePath ? resolvePathLinkTarget(relativePath, cwd) : null;
@@ -800,7 +806,11 @@ export default function FilePreviewPanel({
800806
pressed={renderMarkdown}
801807
onPressedChange={(pressed) => {
802808
setRenderMarkdownPreferred(pressed);
803-
setRevealHandledRequestId(pressed ? revealRequestId : null);
809+
setHandledReveal(
810+
pressed && relativePath !== null
811+
? { path: relativePath, requestId: revealRequestId }
812+
: null,
813+
);
804814
try {
805815
setLocalStorageItem(RENDER_MARKDOWN_STORAGE_KEY, pressed, Schema.Boolean);
806816
} catch (error) {

0 commit comments

Comments
 (0)