TypeScript
perf(web): the file preview panel compiles with the React Compiler (#20692)
Julius Marminge06299ff56ad6
diff --git a/apps/web/src/components/files/FilePreviewPanel.tsx b/apps/web/src/components/files/FilePreviewPanel.tsxindex 20c2160b307..6a81ef7c4fe 100644--- a/apps/web/src/components/files/FilePreviewPanel.tsx+++ b/apps/web/src/components/files/FilePreviewPanel.tsx@@ -40,7 +40,7 @@ import { mediaFileReference } from "@t3tools/client-runtime/media-reference";import { FolderTree, Globe2, WrapTextIcon } from "lucide-react";import { Code2, Eye, Table2 } from "lucide";import * as Schema from "effect/Schema";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useRef, useState } from "react";import { isBrowserPreviewFile, openFileInPreview } from "~/browser/openFileInPreview";import { useAssetUrlRefresh, useAssetUrlState } from "~/assets/assetUrls";@@ -158,17 +158,13 @@ function WorkspaceImagePreview(props: {readonly alt: string;readonly workspaceMutationId: string | null;}) {- const resource = useMemo(- () =>- workspaceAssetResource({- kind: "workspace-file",- threadRef: props.threadRef,- draft: props.draft,- workspaceRoot: props.workspaceRoot,- absolutePath: props.absolutePath,- }),- [props.threadRef, props.draft, props.workspaceRoot, props.absolutePath],- );+ const resource = workspaceAssetResource({+ kind: "workspace-file",+ threadRef: props.threadRef,+ draft: props.draft,+ workspaceRoot: props.workspaceRoot,+ absolutePath: props.absolutePath,+ });const assetUrl = useAssetUrlState(props.environmentId, resource);const [failedUrl, setFailedUrl] = useState<string | null>(null);const revisionSuffix =@@ -228,17 +224,13 @@ function WorkspaceBrowserPreview(props: {}) {const insideWorkspace =mediaFileReference(props.absolutePath, props.workspaceRoot).relativePath !== undefined;- const resource = useMemo(- () =>- workspaceAssetResource({- kind: insideWorkspace ? "workspace-file" : "media-file",- threadRef: props.threadRef,- draft: props.draft,- workspaceRoot: props.workspaceRoot,- absolutePath: props.absolutePath,- }),- [insideWorkspace, props.threadRef, props.draft, props.workspaceRoot, props.absolutePath],- );+ const resource = workspaceAssetResource({+ kind: insideWorkspace ? "workspace-file" : "media-file",+ threadRef: props.threadRef,+ draft: props.draft,+ workspaceRoot: props.workspaceRoot,+ absolutePath: props.absolutePath,+ });const assetUrl = useAssetUrlState(props.environmentId, resource);const revisionSuffix =props.workspaceMutationId === null@@ -277,17 +269,13 @@ function WorkspaceVideoPreview(props: {readonly name: string;readonly workspaceMutationId: string | null;}) {- const resource = useMemo(- () =>- workspaceAssetResource({- kind: "media-file",- threadRef: props.threadRef,- draft: props.draft,- workspaceRoot: props.workspaceRoot,- absolutePath: props.absolutePath,- }),- [props.threadRef, props.draft, props.workspaceRoot, props.absolutePath],- );+ const resource = workspaceAssetResource({+ kind: "media-file",+ threadRef: props.threadRef,+ draft: props.draft,+ workspaceRoot: props.workspaceRoot,+ absolutePath: props.absolutePath,+ });const assetUrl = useAssetUrlState(props.environmentId, resource);const refreshAssetUrl = useAssetUrlRefresh(props.environmentId, resource);useWorkspaceMutationRefresh({@@ -334,17 +322,13 @@ function WorkspaceAudioPreview(props: {readonly name: string;readonly workspaceMutationId: string | null;}) {- const resource = useMemo(- () =>- workspaceAssetResource({- kind: "media-file",- threadRef: props.threadRef,- draft: props.draft,- workspaceRoot: props.workspaceRoot,- absolutePath: props.absolutePath,- }),- [props.threadRef, props.draft, props.workspaceRoot, props.absolutePath],- );+ const resource = workspaceAssetResource({+ kind: "media-file",+ threadRef: props.threadRef,+ draft: props.draft,+ workspaceRoot: props.workspaceRoot,+ absolutePath: props.absolutePath,+ });const assetUrl = useAssetUrlState(props.environmentId, resource);const refreshAssetUrl = useAssetUrlRefresh(props.environmentId, resource);const [failedUrl, setFailedUrl] = useState<string | null>(null);@@ -427,164 +411,161 @@ function useFileLineReveal(): FilePostRender {const [revealStatesByPath] = useState(() => new Map<string, FileRevealState>());- return useCallback<FilePostRender>(- (fileContainer, instance, phase) => {- if (relativePath === null) return;-- const existingState = revealStatesByPath.get(relativePath);- const state: FileRevealState = existingState ?? {- frameId: null,- cancelGuard: null,- handledRequestId: null,- latestRequestId: null,- };- if (!existingState) revealStatesByPath.set(relativePath, state);+ return (fileContainer, instance, phase) => {+ if (relativePath === null) return;- const cancelPendingReveal = () => {- if (state.frameId !== null) {- cancelAnimationFrame(state.frameId);- state.frameId = null;- }- state.cancelGuard?.();- };+ const existingState = revealStatesByPath.get(relativePath);+ const state: FileRevealState = existingState ?? {+ frameId: null,+ cancelGuard: null,+ handledRequestId: null,+ latestRequestId: null,+ };+ if (!existingState) revealStatesByPath.set(relativePath, state);- if (phase === "unmount") {- cancelPendingReveal();- return;+ const cancelPendingReveal = () => {+ if (state.frameId !== null) {+ cancelAnimationFrame(state.frameId);+ state.frameId = null;}+ state.cancelGuard?.();+ };- const contents = instance.file?.contents;- const targetLine =- revealLine === null || contents === undefined ? null : clampFileLine(contents, revealLine);- updateFileLinkReveal(fileContainer, targetLine);+ if (phase === "unmount") {+ cancelPendingReveal();+ return;+ }- if (!(instance instanceof VirtualizedFile)) return;+ const contents = instance.file?.contents;+ const targetLine =+ revealLine === null || contents === undefined ? null : clampFileLine(contents, revealLine);+ updateFileLinkReveal(fileContainer, targetLine);- if (state.latestRequestId !== revealRequestId) {- cancelPendingReveal();- state.latestRequestId = revealRequestId;- state.handledRequestId = null;- }+ if (!(instance instanceof VirtualizedFile)) return;- if (revealLine === null) {- fileContainer.style.minHeight = "";- return;- }+ if (state.latestRequestId !== revealRequestId) {+ cancelPendingReveal();+ state.latestRequestId = revealRequestId;+ state.handledRequestId = null;+ }- const scrollContainer = fileContainer.closest<HTMLElement>(".file-preview-virtualizer");- if (!scrollContainer) return;- fileContainer.style.minHeight = `${Math.ceil(- Math.max(instance.height, scrollContainer.clientHeight),- )}px`;+ if (revealLine === null) {+ fileContainer.style.minHeight = "";+ return;+ }- if (state.handledRequestId === revealRequestId || state.frameId !== null) {- return;- }+ const scrollContainer = fileContainer.closest<HTMLElement>(".file-preview-virtualizer");+ if (!scrollContainer) return;+ fileContainer.style.minHeight = `${Math.ceil(+ Math.max(instance.height, scrollContainer.clientHeight),+ )}px`;- const resolveScrollTarget = (line: number): number | null => {- const linePosition = instance.getLinePosition(line);- if (!linePosition) return null;+ if (state.handledRequestId === revealRequestId || state.frameId !== null) {+ return;+ }- const scrollContainerRect = scrollContainer.getBoundingClientRect();- const fileTop =- scrollContainer.scrollTop +- fileContainer.getBoundingClientRect().top -- scrollContainerRect.top;- const root = fileContainer.shadowRoot ?? fileContainer;- const renderedLineElement = root.querySelector<HTMLElement>(`[data-line="${line}"]`);- const renderedLineRect = renderedLineElement?.getBoundingClientRect();+ const resolveScrollTarget = (line: number): number | null => {+ const linePosition = instance.getLinePosition(line);+ if (!linePosition) return null;- return resolveCenteredFileLineScrollTop({- scrollTop: scrollContainer.scrollTop,- scrollHeight: scrollContainer.scrollHeight,- viewportTop: scrollContainerRect.top,- viewportHeight: scrollContainer.clientHeight,- fileTop,- estimatedLine: linePosition,- ...(renderedLineRect && renderedLineRect.height > 0- ? {- renderedLine: {- top: renderedLineRect.top,- height: renderedLineRect.height,- },- }- : {}),- });- };+ const scrollContainerRect = scrollContainer.getBoundingClientRect();+ const fileTop =+ scrollContainer.scrollTop ++ fileContainer.getBoundingClientRect().top -+ scrollContainerRect.top;+ const root = fileContainer.shadowRoot ?? fileContainer;+ const renderedLineElement = root.querySelector<HTMLElement>(`[data-line="${line}"]`);+ const renderedLineRect = renderedLineElement?.getBoundingClientRect();++ return resolveCenteredFileLineScrollTop({+ scrollTop: scrollContainer.scrollTop,+ scrollHeight: scrollContainer.scrollHeight,+ viewportTop: scrollContainerRect.top,+ viewportHeight: scrollContainer.clientHeight,+ fileTop,+ estimatedLine: linePosition,+ ...(renderedLineRect && renderedLineRect.height > 0+ ? {+ renderedLine: {+ top: renderedLineRect.top,+ height: renderedLineRect.height,+ },+ }+ : {}),+ });+ };- const guardScrollTarget = (line: number) => {- let framesLeft = REVEAL_GUARD_FRAMES;- let guardFrameId: number | null = null;- const cancelGuard = () => {- if (guardFrameId !== null) {- cancelAnimationFrame(guardFrameId);- guardFrameId = null;- }- scrollContainer.removeEventListener("wheel", cancelGuard);- scrollContainer.removeEventListener("touchstart", cancelGuard);- scrollContainer.removeEventListener("pointerdown", cancelGuard, true);- window.removeEventListener("keydown", cancelGuard, true);- if (state.cancelGuard === cancelGuard) state.cancelGuard = null;- };- scrollContainer.addEventListener("wheel", cancelGuard, { passive: true });- scrollContainer.addEventListener("touchstart", cancelGuard, { passive: true });- // Pierre stops gutter pointer events from bubbling. Listen in capture- // so starting a comment cancels the reveal guard before the row expands.- scrollContainer.addEventListener("pointerdown", cancelGuard, {- passive: true,- capture: true,- });- window.addEventListener("keydown", cancelGuard, true);- const holdTarget = () => {+ const guardScrollTarget = (line: number) => {+ let framesLeft = REVEAL_GUARD_FRAMES;+ let guardFrameId: number | null = null;+ const cancelGuard = () => {+ if (guardFrameId !== null) {+ cancelAnimationFrame(guardFrameId);guardFrameId = null;- framesLeft -= 1;- if (framesLeft <= 0 || !scrollContainer.isConnected) {- cancelGuard();- return;- }- const targetTop = resolveScrollTarget(line);- if (- targetTop !== null &&- Math.abs(scrollContainer.scrollTop - targetTop) > REVEAL_GUARD_TOLERANCE_PX- ) {- scrollContainer.scrollTop = targetTop;- }- guardFrameId = requestAnimationFrame(holdTarget);- };+ }+ scrollContainer.removeEventListener("wheel", cancelGuard);+ scrollContainer.removeEventListener("touchstart", cancelGuard);+ scrollContainer.removeEventListener("pointerdown", cancelGuard, true);+ window.removeEventListener("keydown", cancelGuard, true);+ if (state.cancelGuard === cancelGuard) state.cancelGuard = null;+ };+ scrollContainer.addEventListener("wheel", cancelGuard, { passive: true });+ scrollContainer.addEventListener("touchstart", cancelGuard, { passive: true });+ // Pierre stops gutter pointer events from bubbling. Listen in capture+ // so starting a comment cancels the reveal guard before the row expands.+ scrollContainer.addEventListener("pointerdown", cancelGuard, {+ passive: true,+ capture: true,+ });+ window.addEventListener("keydown", cancelGuard, true);+ const holdTarget = () => {+ guardFrameId = null;+ framesLeft -= 1;+ if (framesLeft <= 0 || !scrollContainer.isConnected) {+ cancelGuard();+ return;+ }+ const targetTop = resolveScrollTarget(line);+ if (+ targetTop !== null &&+ Math.abs(scrollContainer.scrollTop - targetTop) > REVEAL_GUARD_TOLERANCE_PX+ ) {+ scrollContainer.scrollTop = targetTop;+ }guardFrameId = requestAnimationFrame(holdTarget);- state.cancelGuard = cancelGuard;};+ guardFrameId = requestAnimationFrame(holdTarget);+ state.cancelGuard = cancelGuard;+ };- const scheduleReveal = (attempt: number) => {- state.frameId = requestAnimationFrame(() => {- state.frameId = null;- if (state.latestRequestId !== revealRequestId || !fileContainer.isConnected) {- return;- }+ const scheduleReveal = (attempt: number) => {+ state.frameId = requestAnimationFrame(() => {+ state.frameId = null;+ if (state.latestRequestId !== revealRequestId || !fileContainer.isConnected) {+ return;+ }- // Contents and line metrics can lag the first post-render on fresh- // mounts; clamping against missing contents would scroll to line 1- // and wrongly mark the request handled.- const currentContents = instance.file?.contents;- const line =- currentContents === undefined ? null : clampFileLine(currentContents, revealLine);- const targetTop = line === null ? null : resolveScrollTarget(line);- if (line === null || targetTop === null) {- if (attempt < REVEAL_MAX_ATTEMPTS) scheduleReveal(attempt + 1);- return;- }- updateFileLinkReveal(fileContainer, line);+ // Contents and line metrics can lag the first post-render on fresh+ // mounts; clamping against missing contents would scroll to line 1+ // and wrongly mark the request handled.+ const currentContents = instance.file?.contents;+ const line =+ currentContents === undefined ? null : clampFileLine(currentContents, revealLine);+ const targetTop = line === null ? null : resolveScrollTarget(line);+ if (line === null || targetTop === null) {+ if (attempt < REVEAL_MAX_ATTEMPTS) scheduleReveal(attempt + 1);+ return;+ }+ updateFileLinkReveal(fileContainer, line);- scrollContainer.scrollTop = targetTop;- state.handledRequestId = revealRequestId;- guardScrollTarget(line);- });- };+ scrollContainer.scrollTop = targetTop;+ state.handledRequestId = revealRequestId;+ guardScrollTarget(line);+ });+ };- scheduleReveal(0);- },- [revealStatesByPath, relativePath, revealLine, revealRequestId],- );+ scheduleReveal(0);+ };}const createFileEditor: EditorFactory<FileCommentAnnotationGroup, undefined> = (@@ -628,7 +609,7 @@ function needsWorkerHighlight(workerPool: WorkerPoolManager | undefined, file: Ffunction useEditableAfterHighlight(file: FileContents) {const workerPool = useWorkerPool();const [highlightedFile, setHighlightedFile] = useState<FileContents | null>(null);- const needsHighlight = useMemo(() => needsWorkerHighlight(workerPool, file), [file, workerPool]);+ const needsHighlight = needsWorkerHighlight(workerPool, file);const ready = !needsHighlight || highlightedFile === file;useEffect(() => {@@ -636,15 +617,12 @@ function useEditableAfterHighlight(file: FileContents) {workerPool.primeFileHighlightCache(file).catch(() => setHighlightedFile(file));}, [file, ready, workerPool]);- const onPostRender = useCallback(- (renderedFile: FileContents | undefined, phase: PostRenderPhase) => {- if (ready || phase === "unmount" || renderedFile?.cacheKey !== file.cacheKey) return;- // The pool caches a result just before the instance renders it, so a- // render that sees the cache has painted highlighted rows.- if (workerPool?.getFileResultCache(file) !== undefined) setHighlightedFile(file);- },- [file, ready, workerPool],- );+ const onPostRender = (renderedFile: FileContents | undefined, phase: PostRenderPhase) => {+ if (ready || phase === "unmount" || renderedFile?.cacheKey !== file.cacheKey) return;+ // The pool caches a result just before the instance renders it, so a+ // render that sees the cache has painted highlighted rows.+ if (workerPool?.getFileResultCache(file) !== undefined) setHighlightedFile(file);+ };return { ready, onPostRender };}@@ -684,12 +662,9 @@ function EditableFileSurface({const [selectionOverride, setSelectionOverride] = useState<FileSelectionOverride | null>(null);const selectedRange =selectionOverride?.revealRequestId === revealRequestId ? selectionOverride.range : null;- const setSelectedRange = useCallback(- (range: SelectedLineRange | null) => {- setSelectionOverride({ revealRequestId, range });- },- [revealRequestId],- );+ const setSelectedRange = (range: SelectedLineRange | null) => {+ setSelectionOverride({ revealRequestId, range });+ };const surfaceRef = useRef<HTMLDivElement>(null);const selectionFrameRef = useRef<number | null>(null);const saveCoordinator = useFileSaveCoordinator({@@ -711,72 +686,30 @@ function EditableFileSurface({const { ready: editable, onPostRender: onEditablePostRender } =useEditableAfterHighlight(externalFile);const editorRef = useRef<Editor<"file", FileCommentAnnotationGroup, undefined> | null>(null);- const editorOptions = useMemo<EditorOptions<"file", FileCommentAnnotationGroup, undefined>>(- () => ({- onAttach: (editor) => {- editorRef.current = editor;- },- onComplete: () => {- editorRef.current = null;- },- }),- [],- );-- const handleEditChange = useCallback(- ({- file,- lineAnnotations: nextLineAnnotations,- }: EditorChangeEvent<"file", FileCommentAnnotationGroup, undefined>) => {- if (file.contents === getProjectFileContents(environmentId, cwd, relativePath)) return;- setEditedContents(file.contents);- setProjectFileQueryData(environmentId, cwd, relativePath, file.contents);- saveCoordinator.change(file.contents);- if (!nextLineAnnotations) return;- const remapped = remapFileCommentAnnotations(nextLineAnnotations);- // The editor hands back the array it was given until an edit moves an annotation.- setLineAnnotations((current) => (current === nextLineAnnotations ? current : remapped));- for (const annotation of remapped) {- for (const entry of annotation.metadata.entries) {- if (entry.kind !== "comment") continue;- addReviewComment(- composerDraftTarget,- buildFileReviewComment({- id: entry.id,- filePath: relativePath,- startLine: entry.startLine,- endLine: entry.endLine,- text: entry.text,- contents: file.contents,- }),- );- }- }+ const editorOptions: EditorOptions<"file", FileCommentAnnotationGroup, undefined> = {+ onAttach: (editor) => {+ editorRef.current = editor;},- [addReviewComment, composerDraftTarget, cwd, environmentId, relativePath, saveCoordinator],- );-- const removeAnnotationEntry = useCallback(- (entryId: string) => {- setSelectedRange(null);- removeReviewComment(composerDraftTarget, entryId);- setLineAnnotations((current) => {- return current.flatMap((annotation) => {- const entries = annotation.metadata.entries.filter((entry) => entry.id !== entryId);- return entries.length > 0 ? [{ ...annotation, metadata: { entries } }] : [];- });- });+ onComplete: () => {+ editorRef.current = null;},- [composerDraftTarget, removeReviewComment, setSelectedRange],- );+ };- const submitAnnotationEntry = useCallback(- (entryId: string, text: string) => {- setSelectedRange(null);- const entry = lineAnnotations- .flatMap((annotation) => annotation.metadata.entries)- .find((candidate) => candidate.id === entryId);- if (entry) {+ const handleEditChange = ({+ file,+ lineAnnotations: nextLineAnnotations,+ }: EditorChangeEvent<"file", FileCommentAnnotationGroup, undefined>) => {+ if (file.contents === getProjectFileContents(environmentId, cwd, relativePath)) return;+ setEditedContents(file.contents);+ setProjectFileQueryData(environmentId, cwd, relativePath, file.contents);+ saveCoordinator.change(file.contents);+ if (!nextLineAnnotations) return;+ const remapped = remapFileCommentAnnotations(nextLineAnnotations);+ // The editor hands back the array it was given until an edit moves an annotation.+ setLineAnnotations((current) => (current === nextLineAnnotations ? current : remapped));+ for (const annotation of remapped) {+ for (const entry of annotation.metadata.entries) {+ if (entry.kind !== "comment") continue;addReviewComment(composerDraftTarget,buildFileReviewComment({@@ -784,35 +717,58 @@ function EditableFileSurface({filePath: relativePath,startLine: entry.startLine,endLine: entry.endLine,- text,- contents,+ text: entry.text,+ contents: file.contents,}),);}- setLineAnnotations((current) =>- current.map((annotation) => ({- ...annotation,- metadata: {- entries: annotation.metadata.entries.map((annotationEntry) =>- annotationEntry.id === entryId- ? { ...annotationEntry, kind: "comment", text }- : annotationEntry,- ),- },- })),+ }+ };++ const removeAnnotationEntry = (entryId: string) => {+ setSelectedRange(null);+ removeReviewComment(composerDraftTarget, entryId);+ setLineAnnotations((current) => {+ return current.flatMap((annotation) => {+ const entries = annotation.metadata.entries.filter((entry) => entry.id !== entryId);+ return entries.length > 0 ? [{ ...annotation, metadata: { entries } }] : [];+ });+ });+ };++ const submitAnnotationEntry = (entryId: string, text: string) => {+ setSelectedRange(null);+ const entry = lineAnnotations+ .flatMap((annotation) => annotation.metadata.entries)+ .find((candidate) => candidate.id === entryId);+ if (entry) {+ addReviewComment(+ composerDraftTarget,+ buildFileReviewComment({+ id: entry.id,+ filePath: relativePath,+ startLine: entry.startLine,+ endLine: entry.endLine,+ text,+ contents,+ }),);- },- [- addReviewComment,- composerDraftTarget,- contents,- lineAnnotations,- relativePath,- setSelectedRange,- ],- );+ }+ setLineAnnotations((current) =>+ current.map((annotation) => ({+ ...annotation,+ metadata: {+ entries: annotation.metadata.entries.map((annotationEntry) =>+ annotationEntry.id === entryId+ ? { ...annotationEntry, kind: "comment", text }+ : annotationEntry,+ ),+ },+ })),+ );+ };- const beginComment = useCallback((range: SelectedLineRange) => {+ const beginComment = (range: SelectedLineRange) => {editorRef.current?.setSelections([]);editorRef.current?.blur();const { startLine, endLine } = normalizeFileCommentRange(range);@@ -849,7 +805,7 @@ function EditableFileSurface({: annotation,);});- }, []);+ };const hasOpenCommentForm = lineAnnotations.some((annotation) =>annotation.metadata.entries.some((entry) => entry.kind === "draft"),);@@ -863,35 +819,29 @@ function EditableFileSurface({onDismiss: () => setSelectedRange(null),});}, [hasOpenCommentForm, setSelectedRange]);- const handleLineSelectionEnd = useCallback(- (range: SelectedLineRange | null) => {- setSelectedRange(range);- if (range) {- beginComment(range);- }- },- [beginComment, setSelectedRange],- );+ const handleLineSelectionEnd = (range: SelectedLineRange | null) => {+ setSelectedRange(range);+ if (range) {+ beginComment(range);+ }+ };- const handlePostRender = useCallback<FilePostRender>(- (fileContainer, instance, phase) => {- onPostRender(fileContainer, instance, phase);- onEditablePostRender(instance.file, phase);+ const handlePostRender: FilePostRender = (fileContainer, instance, phase) => {+ onPostRender(fileContainer, instance, phase);+ onEditablePostRender(instance.file, phase);- if (selectionFrameRef.current !== null) {- cancelAnimationFrame(selectionFrameRef.current);- selectionFrameRef.current = null;- }- if (phase === "unmount") return;+ if (selectionFrameRef.current !== null) {+ cancelAnimationFrame(selectionFrameRef.current);+ selectionFrameRef.current = null;+ }+ if (phase === "unmount") return;- selectionFrameRef.current = requestAnimationFrame(() => {- selectionFrameRef.current = null;- if (!fileContainer.isConnected) return;- instance.setSelectedLines(selectedRange, { notify: false });- });- },- [onEditablePostRender, onPostRender, selectedRange],- );+ selectionFrameRef.current = requestAnimationFrame(() => {+ selectionFrameRef.current = null;+ if (!fileContainer.isConnected) return;+ instance.setSelectedLines(selectedRange, { notify: false });+ });+ };return (<EditProvider createEditor={createFileEditor}>@@ -1191,6 +1141,7 @@ export default function FilePreviewPanel({breadcrumbRef.current?.querySelector<HTMLElement>("[data-current-file-crumb='true']")?.scrollIntoView({ block: "nearest", inline: "nearest" });+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A new path or trail re-renders the crumbs, so the current one scrolls back into view.}, [breadcrumbPath, breadcrumbTrail]);const toggleExplorer = () => {@@ -1205,7 +1156,7 @@ export default function FilePreviewPanel({});};- const handleOpenInBrowser = useCallback(() => {+ const handleOpenInBrowser = () => {if (!canReadFiles || !canOperatePreview || !absolutePath || !environmentHttpBaseUrl) return;void (async () => {const result = await openFileInPreview({@@ -1228,16 +1179,7 @@ export default function FilePreviewPanel({}),);})();- }, [- absolutePath,- canReadFiles,- canOperatePreview,- createAssetUrl,- cwd,- environmentHttpBaseUrl,- openPreview,- threadRef,- ]);+ };if (attachment === undefined && !canReadFiles) {if (fileAccess.isPending) {