From e4c9366d5cef08800ecc904392ff69ae8a3c0289 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Fri, 13 Nov 2026 01:21:39 +0800 Subject: [PATCH] chore(compat): drop unused GitLens store and folder-icon parameter --- src/client/FileTree.tsx | 6 +++--- src/client/changes/ChangesTab.tsx | 3 +-- src/client/changes/GitLens.tsx | 7 ++----- src/client/file-icons.tsx | 3 +-- src/client/service.ts | 2 +- tests/file-icons.spec.tsx | 9 ++++----- tests/git-remote-actions-ui.spec.tsx | 2 -- tests/git-repo-switcher.spec.tsx | 3 +-- tests/git-scm.spec.tsx | 4 +--- tests/git-suggest.spec.tsx | 2 -- tests/git-view-worktree.spec.tsx | 2 -- 11 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/client/FileTree.tsx b/src/client/FileTree.tsx index a421f275..d0900e1f 100644 --- a/src/client/FileTree.tsx +++ b/src/client/FileTree.tsx @@ -421,7 +421,7 @@ const DirRow = memo(function DirRow(props: DirRowProps): ReactNode { // the user sees expanded (`a/b/c`), so dropping into it, renaming it or // opening a menu on it must address `c`, not the fold head `a`. const target = chain[chain.length - 1]! - const icon = service !== undefined ? service.folderIcon(target.path, expanded, 14) : builtinFolderIcon(expanded, 14) + const icon = service !== undefined ? service.folderIcon(target.path, expanded, 14) : builtinFolderIcon(14) return (
- service !== undefined ? service.folderIcon(path, open, 14) : builtinFolderIcon(open, 14) + service !== undefined ? service.folderIcon(path, open, 14) : builtinFolderIcon(14) const dataRef = useRef(data) /** Bumped whenever the cache is wiped: a response from an older generation is dropped. */ const generationRef = useRef(0) diff --git a/src/client/changes/ChangesTab.tsx b/src/client/changes/ChangesTab.tsx index dc2c7ba9..c510542d 100644 --- a/src/client/changes/ChangesTab.tsx +++ b/src/client/changes/ChangesTab.tsx @@ -79,7 +79,7 @@ type PreviewSelection = | { kind: 'git'; ref: SidebarDiffRef } | { kind: 'op'; path: string; callId: string } -export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpenDiff }: TabComponentProps) { +export function ChangesTab({ ctx, scope, tab, visible, onOpenFile, onOpenDiff }: TabComponentProps) { const meta = (tab.meta ?? {}) as ChangesMeta const lensId = useId() const [lens, setLens] = useState(meta.lens === 'session' ? 'session' : 'git') @@ -278,7 +278,6 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen { /* no-op */ })} diff --git a/src/client/changes/GitLens.tsx b/src/client/changes/GitLens.tsx index ab50c4af..eeba9809 100644 --- a/src/client/changes/GitLens.tsx +++ b/src/client/changes/GitLens.tsx @@ -23,7 +23,7 @@ import { baseName, relativeTo } from '../paths.ts' import { resolveSidebarPath } from '../paths.ts' import { isZh, t } from '../locales.ts' import { GitGraphSection, type GraphDetailsSelection } from './GitGraphSection.tsx' -import type { SidebarDiffRef, SidebarStore } from '../state.ts' +import type { SidebarDiffRef } from '../state.ts' import { ConfirmDialog, IconButton, Notice, StatusBadge, invalidateGitStatus, statusOfXY, useGitStatus, type GitFileStatus, type GitTone, type StatusTone, @@ -358,9 +358,6 @@ type CommitRow = Pick export interface GitLensProps { scope: SessionScope - /** @deprecated The sidebar store is no longer read here (the fence guard it - * fed is gone); the prop stays for the caller's shape. */ - store: SidebarStore onOpenFile: (path: string) => void /** Preview one change in the shared bottom pane (worktree or commit ref). */ onPreview: (ref: SidebarDiffRef) => void @@ -397,7 +394,7 @@ export function GitLens(props: GitLensProps) { service === undefined ? builtinFileIcon(path, 14) : service.fileIcon(path, 14) ), [service]) const folderGlyph = useCallback((path: string, open: boolean): ReactNode => ( - service === undefined ? builtinFolderIcon(open, 14) : service.folderIcon(path, open, 14) + service === undefined ? builtinFolderIcon(14) : service.folderIcon(path, open, 14) ), [service]) const [worktrees, setWorktrees] = useState([]) diff --git a/src/client/file-icons.tsx b/src/client/file-icons.tsx index 5fe16990..4457dce0 100644 --- a/src/client/file-icons.tsx +++ b/src/client/file-icons.tsx @@ -42,11 +42,10 @@ export function builtinFileIcon(path: string, size: number): ReactNode { * its own. The expansion state is already legible from the tree's own chevron * and row affordances, so this deliberately does not invent a second folder * drawing. - * @param _open - whether the row is expanded (accepted for API compatibility). * @param size - the square edge in px. * @returns the host's folder glyph. */ -export function builtinFolderIcon(_open: boolean, size: number): ReactNode { +export function builtinFolderIcon(size: number): ReactNode { return } diff --git a/src/client/service.ts b/src/client/service.ts index 02a9e38c..34d18f03 100644 --- a/src/client/service.ts +++ b/src/client/service.ts @@ -1286,7 +1286,7 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe const icon = safeIcon(registered, path, size, open) if (icon !== undefined) return icon } - return builtinFolderIcon(open, size) + return builtinFolderIcon(size) } // The enable switches come from the user's side card prefs (the shared diff --git a/tests/file-icons.spec.tsx b/tests/file-icons.spec.tsx index 6b4b6221..8eea3fca 100644 --- a/tests/file-icons.spec.tsx +++ b/tests/file-icons.spec.tsx @@ -232,8 +232,7 @@ describe('folderIcon resolver (registered folder/folder-open → the host folder const service = createBetterSidebarService(createSidebarStore()) expect(glyphOf(service.folderIcon('/w/src', false, 14))).toBe(FileTypeIcon) expect(glyphOf(service.folderIcon('/w/src', true, 14))).toBe(FileTypeIcon) - expect(glyphOf(builtinFolderIcon(false, 14))).toBe(FileTypeIcon) - expect(glyphOf(builtinFolderIcon(true, 14))).toBe(FileTypeIcon) + expect(glyphOf(builtinFolderIcon(14))).toBe(FileTypeIcon) }) it('folder / folder-open registrations replace the dir glyphs (priority desc)', () => { @@ -283,10 +282,10 @@ describe('built-in glyphs are the host’s own artwork', () => { }) it('renders the host folder category for directories', () => { - const props = (builtinFolderIcon(false, 14) as ReactElement).props as { kind: string; size: number } + const props = (builtinFolderIcon(14) as ReactElement).props as { kind: string; size: number } expect(props.kind).toBe('folder') expect(props.size).toBe(14) - // Both expansion states resolve to the host's folder drawing. - expect(glyphOf(builtinFolderIcon(true, 14))).toBe(FileTypeIcon) + // The host ships one folder drawing; expansion state is the tree's chevron. + expect(glyphOf(builtinFolderIcon(14))).toBe(FileTypeIcon) }) }) diff --git a/tests/git-remote-actions-ui.spec.tsx b/tests/git-remote-actions-ui.spec.tsx index 987b5d42..4c650aa7 100644 --- a/tests/git-remote-actions-ui.spec.tsx +++ b/tests/git-remote-actions-ui.spec.tsx @@ -16,7 +16,6 @@ import { createElement } from 'react' import { createRoot, type Root } from 'react-dom/client' import { act } from 'react-dom/test-utils' import { GitLens } from '../src/client/changes/GitLens.tsx' -import { createSidebarStore } from '../src/client/state.ts' import { api, type GitStatusResult, type GitWorktree } from '../src/client/api.ts' import { t } from '../src/client/locales.ts' @@ -42,7 +41,6 @@ function mountGit(root: Root): void { act(() => { root.render(createElement(GitLens, { scope: { sessionId: 'session', cwd: MAIN }, - store: createSidebarStore(), onOpenFile: () => {}, onPreview: () => {}, selectedRef: null, diff --git a/tests/git-repo-switcher.spec.tsx b/tests/git-repo-switcher.spec.tsx index df8387ef..cf6e5b29 100644 --- a/tests/git-repo-switcher.spec.tsx +++ b/tests/git-repo-switcher.spec.tsx @@ -22,7 +22,6 @@ import { act } from 'react-dom/test-utils' import { afterEach, expect, it, vi } from 'vitest' import { api, type GitStatusResult, type SessionScope } from '../src/client/api.ts' import { GitLens } from '../src/client/changes/GitLens.tsx' -import { createSidebarStore } from '../src/client/state.ts' import { renderRoot, setupReactAct } from './test-utils.ts' setupReactAct() @@ -55,7 +54,7 @@ async function mount(options: { sessionId: string; repositories?: string[] }) { isRepo: true, root: CWD, entries: [], branches: [], hasMore: false, snapshot: 'one', }) const view = renderRoot( - {}} onPreview={() => {}} />, ) await flush() diff --git a/tests/git-scm.spec.tsx b/tests/git-scm.spec.tsx index 940a3dce..553f1e7c 100644 --- a/tests/git-scm.spec.tsx +++ b/tests/git-scm.spec.tsx @@ -3,7 +3,6 @@ import { act } from 'react-dom/test-utils' import { afterEach, expect, it, vi } from 'vitest' import { api, type GitStatusResult, type SessionScope } from '../src/client/api.ts' import { GitLens } from '../src/client/changes/GitLens.tsx' -import { createSidebarStore } from '../src/client/state.ts' import { invalidateGitStatus } from '../src/client/ui/git-status.ts' import { t } from '../src/client/locales.ts' import { renderRoot, setupReactAct } from './test-utils.ts' @@ -11,7 +10,6 @@ import { renderRoot, setupReactAct } from './test-utils.ts' setupReactAct() afterEach(() => { vi.restoreAllMocks() }) const CWD = 'C:/repo' -const store = createSidebarStore() /** The unstage artwork the SCM rows draw (the plugin's own inline horizontal half). */ const MINUS_GLYPH = 'M2 8H14' /** The host's own Plus, a document-sprite reference since DSH 0.2.2 (it used @@ -58,7 +56,7 @@ async function mount(readStatus: (scope: SessionScope) => GitStatusResult) { hasMore: false, snapshot: 'one', }) - const render = (sessionId: string) => {}} onPreview={() => {}} /> const view = renderRoot(render('scm-A')) await flush() diff --git a/tests/git-suggest.spec.tsx b/tests/git-suggest.spec.tsx index 746ea3ea..50e0e535 100644 --- a/tests/git-suggest.spec.tsx +++ b/tests/git-suggest.spec.tsx @@ -17,7 +17,6 @@ import { createElement } from 'react' import { createRoot, type Root } from 'react-dom/client' import { act } from 'react-dom/test-utils' import { GitLens } from '../src/client/changes/GitLens.tsx' -import { createSidebarStore } from '../src/client/state.ts' import { api, SidebarApiError, type GitStatusResult } from '../src/client/api.ts' import { setupReactAct } from './test-utils.ts' @@ -52,7 +51,6 @@ async function mount(options: { await act(async () => { root.render(createElement(GitLens, { scope: { sessionId: 'session', cwd: CWD }, - store: createSidebarStore(), onOpenFile: () => {}, onPreview: () => {}, selectedRef: null, diff --git a/tests/git-view-worktree.spec.tsx b/tests/git-view-worktree.spec.tsx index af08b772..a6877f8e 100644 --- a/tests/git-view-worktree.spec.tsx +++ b/tests/git-view-worktree.spec.tsx @@ -15,7 +15,6 @@ import { createElement } from 'react' import { createRoot, type Root } from 'react-dom/client' import { act } from 'react-dom/test-utils' import { GitLens } from '../src/client/changes/GitLens.tsx' -import { createSidebarStore } from '../src/client/state.ts' import { api, type GitStatusEntry, type GitStatusResult, type GitWorktree } from '../src/client/api.ts' import type { BetterSidebarService } from '../src/client/service.ts' import { t } from '../src/client/locales.ts' @@ -91,7 +90,6 @@ function mountGit( act(() => { root.render(createElement(GitLens, { scope: options.scope ?? { sessionId: 'session', cwd: MAIN }, - store: createSidebarStore(), onOpenFile: () => {}, onPreview: () => {}, selectedRef: null,