Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 文件网格大图标恢复与文件夹一致的细描边 (#5364)
Dash1c62e8a48266
diff --git a/apps/mobile/src/__tests__/fileTypeTile.test.tsx b/apps/mobile/src/__tests__/fileTypeTile.test.tsxindex 2f55f6b99e..0f65f8c7a9 100644--- a/apps/mobile/src/__tests__/fileTypeTile.test.tsx+++ b/apps/mobile/src/__tests__/fileTypeTile.test.tsx@@ -1,12 +1,31 @@import { renderToStaticMarkup } from "react-dom/server";import { describe, expect, it, vi } from "vitest";+import { FileTypeIcon } from "@/components/FileTypeIcon";import { FileTypeTile } from "@/components/FileTypeTile";-import { darkColors, lightColors } from "@/theme/tokens";+import { darkColors, iconSize, iconStroke, lightColors } from "@/theme/tokens";const theme = vi.hoisted(() => ({ dark: false }));+const glyphProps = vi.hoisted(() => [] as Array<Record<string, unknown>>);vi.mock("react-native", () => ({ View: "div" }));vi.mock("@/components/AppText", () => ({ Text: "span" }));-vi.mock("@/components/FileTypeIcon", () => ({ FileTypeIcon: () => null }));+vi.mock("lucide-react-native", () => {+ const Glyph = (props: Record<string, unknown>) => {+ glyphProps.push(props);+ return null;+ };+ return {+ Database: Glyph,+ File: Glyph,+ FileArchive: Glyph,+ FileAudio: Glyph,+ FileChartColumn: Glyph,+ FileCode: Glyph,+ FileImage: Glyph,+ FileSpreadsheet: Glyph,+ FileText: Glyph,+ FileVideo: Glyph,+ };+});vi.mock("@/theme", async () => {const tokens = await import("@/theme/tokens");return {@@ -17,13 +36,63 @@ vi.mock("@/theme", async () => {};});+function renderGlyph(node: Parameters<typeof renderToStaticMarkup>[0]) {+ glyphProps.length = 0;+ const html = renderToStaticMarkup(node);+ expect(glyphProps).toHaveLength(1);+ return { html, glyph: glyphProps[0]! };+}+describe("file tile format label", () => {it.each([false, true])("uses high-contrast text in dark=%s", (dark) => {theme.dark = dark;const colors = dark ? darkColors : lightColors;- const html = renderToStaticMarkup(<FileTypeTile name="report.pdf" />);+ const { html } = renderGlyph(<FileTypeTile name="report.pdf" />);expect(html).toContain(`color:${colors.textPrimary}`);expect(html).toContain("font-size:11px");expect(html).toContain(">PDF</span>");});});++describe("file tile glyph stroke", () => {+ it.each([false, true])(+ "keeps the large glyph on the folder's thin absolute stroke in dark=%s",+ (dark) => {+ theme.dark = dark;+ const colors = dark ? darkColors : lightColors;+ const { glyph } = renderGlyph(+ <FileTypeTile name="apply-personal-v5.command" />,+ );+ expect(glyph).toMatchObject({+ size: iconSize.glyph,+ color: colors.borderStrong,+ strokeWidth: iconStroke.thin,+ absoluteStrokeWidth: true,+ });+ },+ );+});++describe("compact file type icon", () => {+ it("defaults to the regular stroke without absolute scaling", () => {+ theme.dark = false;+ const { glyph } = renderGlyph(<FileTypeIcon name="notes.md" />);+ expect(glyph.strokeWidth).toBe(iconStroke.regular);+ expect(glyph.absoluteStrokeWidth).toBeUndefined();+ });++ it("honors a caller-provided stroke", () => {+ theme.dark = false;+ const { glyph } = renderGlyph(+ <FileTypeIcon+ name="notes.md"+ strokeWidth={iconStroke.thin}+ absoluteStrokeWidth+ />,+ );+ expect(glyph).toMatchObject({+ strokeWidth: iconStroke.thin,+ absoluteStrokeWidth: true,+ });+ });+});diff --git a/apps/mobile/src/components/FileTypeIcon.tsx b/apps/mobile/src/components/FileTypeIcon.tsxindex 5a141f64c9..190fa5e1dd 100644--- a/apps/mobile/src/components/FileTypeIcon.tsx+++ b/apps/mobile/src/components/FileTypeIcon.tsx@@ -8,8 +8,9 @@ export function pickFileIcon(name: string, mimeType?: string) {return glyphs[FILE_VISUAL_GLYPHS[getFileVisualKind({ name, mimeType })]];}-export function FileTypeIcon({ name = '', mimeType, size = iconSize.sm, color, ...props }: FileVisualInput & LucideProps) {+/** Compact glyphs default to the regular stroke; large tiles pass their own absolute stroke. */+export function FileTypeIcon({ name = '', mimeType, size = iconSize.sm, color, strokeWidth = iconStroke.regular, ...props }: FileVisualInput & LucideProps) {const { colors } = useTheme();const Icon = pickFileIcon(name, mimeType);- return <Icon size={size} color={color ?? colors.textSecondary} {...props} strokeWidth={iconStroke.regular} accessible={false} />;+ return <Icon size={size} color={color ?? colors.textSecondary} strokeWidth={strokeWidth} {...props} accessible={false} />;}diff --git a/apps/mobile/src/components/FileTypeTile.tsx b/apps/mobile/src/components/FileTypeTile.tsxindex c08c3af4e4..31091c3773 100644--- a/apps/mobile/src/components/FileTypeTile.tsx+++ b/apps/mobile/src/components/FileTypeTile.tsx@@ -1,16 +1,25 @@import { FILE_VISUAL_LABELS, getFileVisualKind, type FileVisualInput } from '@cindy/maker-shared';import { View } from 'react-native';import { Text } from '@/components/AppText';-import { iconSize, lineHeight, spacing, typeScale, useTheme } from '@/theme';+import { iconSize, iconStroke, lineHeight, spacing, typeScale, useTheme } from '@/theme';import { FileTypeIcon } from './FileTypeIcon';-/** Large fallback only; real image/document previews remain owned by their callers. */+/** Large fallback only; real image/document previews remain owned by their callers.+ * The glyph matches the file-browser folder glyph: thin absolute stroke (it must not+ * scale with the 64pt size) on the same light border tone. */export function FileTypeTile({ name, mimeType }: FileVisualInput) {const { colors } = useTheme();const label = FILE_VISUAL_LABELS[getFileVisualKind({ name, mimeType })];return (<View accessible={false} style={{ alignItems: 'center', gap: spacing.xs }}>- <FileTypeIcon name={name} mimeType={mimeType} size={iconSize.glyph} />+ <FileTypeIcon+ name={name}+ mimeType={mimeType}+ size={iconSize.glyph}+ color={colors.borderStrong}+ strokeWidth={iconStroke.thin}+ absoluteStrokeWidth+ />{label ? <Text style={{ color: colors.textPrimary, fontSize: typeScale.micro, lineHeight: lineHeight.micro }}>{label}</Text> : null}</View>);diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex fe8e92d68a..a6bbcf4094 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -1540,7 +1540,7 @@ The execution rulebook for subsequent desktop / mobile UI updates. Sources: the- File identity is classified by `packages/maker-shared/src/filePresentation.ts` on both platforms. Known file names/extensions take precedence; MIME is a fallback for unknown names. This is presentation metadata only, never a decoder or permission decision.- Compact file rows, search results, tabs, mentions, references and diff headers use `FileTypeIcon` / `pickFileIcon`: the same named Lucide glyph on Desktop and Mobile, regular stroke, inherited semantic foreground. At 12–18 px/pt, do not squeeze PDF/DOC/XLS text into the glyph. PDF, prose and word-processing documents may share `FileText`; the filename provides the finer distinction.-- Large attachment and generated-file tiles keep real content previews first. Without a preview, use `FileTypeTile` and the shared type label. Desktop reuses the attachment paper/badge artwork and registered file-badge tokens; Mobile uses the shared Lucide glyph and a separate readable label. Labels must respect the platform micro-text minimum; never scale a labeled tile down into a compact icon.+- Large attachment and generated-file tiles keep real content previews first. Without a preview, use `FileTypeTile` and the shared type label. Desktop reuses the attachment paper/badge artwork and registered file-badge tokens; Mobile uses the shared Lucide glyph and a separate readable label; at the 64 pt `iconSize.glyph` tier that glyph matches the file-browser folder glyph — `iconStroke.thin` with `absoluteStrokeWidth` on `borderStrong` — because Lucide's regular 2-unit stroke would otherwise scale to ~5 pt (2026-10-02). Labels must respect the platform micro-text minimum; never scale a labeled tile down into a compact icon.- Categories cover code/configuration, text, PDF, documents, spreadsheets, presentations, images, audio, video, archives, databases and unknown files. New entry points reuse the shared classifier and platform components instead of adding extension tables.- File-type decoration does not replace upload progress, errors, diff counts, rename/copy status or action icons. Folder navigation, pasted-text actions and generic “files” section icons keep their own semantics. Decorative file glyphs add no focus stop or duplicate accessible label.