From b7c9a376d89dee13cbba06826e75d63c3ccb20a3 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Sun, 11 Oct 2026 22:58:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(jsonl):=20=E8=B6=85=E9=99=90=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=8F=AA=E5=9C=A8=E7=9C=9F=E7=9A=84=E8=B6=85=E9=99=90?= =?UTF-8?q?=E6=97=B6=E6=89=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 预览态的 JSONL(小于编辑上限)走的是同一套分页记录视图,但顶部那段 「文件过大,仅提供分页预览」对它是一句谎话——阈值决定提示,不是组件 决定。LargeFileView 现在自己按 MAX_EDITABLE_BYTES 判断。 --- src/client/LargeFileView.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/client/LargeFileView.tsx b/src/client/LargeFileView.tsx index 3b3974cb..e0b6468a 100644 --- a/src/client/LargeFileView.tsx +++ b/src/client/LargeFileView.tsx @@ -24,7 +24,7 @@ import clsx from 'clsx' import { IconChevronLeftOutlineRegular, IconChevronRightOutlineRegular, IconRefreshOutlineRegular, JsonTree, type JsonTreeLabels } from '@deepseek-ai/dsh-client-ui-primitives' import type { SessionScope } from './api.ts' import { downloadUrl } from './api.ts' -import { formatByteSize, MAX_EDITABLE_LABEL } from '../editor-limits.ts' +import { formatByteSize, MAX_EDITABLE_BYTES, MAX_EDITABLE_LABEL } from '../editor-limits.ts' import { isJsonlPath, isTreeRecord, parseRecord, summarizeRecord } from './jsonl.ts' import { splitLines, useTextPager } from './text-pages.ts' import { t } from './locales.ts' @@ -69,6 +69,15 @@ export function LargeFileView(props: { const { scope, path, size, visible, revision } = props const pager = useTextPager(scope, path, visible, revision) const records = isJsonlPath(path) + /** + * Whether this file is over the EDITABLE threshold — which is a different + * question from "is this view paged". + * + * A small `.jsonl` opens straight into this record list as its PREVIEW, and + * announcing "the file is too large, paged preview only" over a 2 KB file + * would be a lie. The threshold decides, not the component. + */ + const tooLarge = size > MAX_EDITABLE_BYTES const rows = useMemo(() => splitLines(pager.text), [pager.text]) /** Which record rows are expanded (reset with every page). */ const [expanded, setExpanded] = useState>(new Set()) @@ -90,12 +99,14 @@ export function LargeFileView(props: { return (
-
- {t('previewOnlyNotice', { size: formatByteSize(size), limit: MAX_EDITABLE_LABEL })} - - {t('downloadToView')} - -
+ {tooLarge && ( +
+ {t('previewOnlyNotice', { size: formatByteSize(size), limit: MAX_EDITABLE_LABEL })} + + {t('downloadToView')} + +
+ )}
{pager.error !== null &&
{pager.error}
} {pager.error === null && pager.loading && pager.text === '' && (