chore(compat): drop unused GitLens store and folder-icon parameter

This commit is contained in:
Menghuan1918 committed 2026-11-13 01:21:39 +08:00
1 parent c56c6efeff
commit e4c9366d5c
11 files changed
+14 -29

No files matched your search

+3 -3
View File
@@ -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 (
<div
role="button"
@@ -499,7 +499,7 @@ interface RootRowProps {
const RootRow = memo(function RootRow(props: RootRowProps): ReactNode {
const { path, iconsVersion, service, dropTarget, gitChanged, copied, actions } = props
void iconsVersion
const icon = service !== undefined ? service.folderIcon(path, true, 14) : builtinFolderIcon(true, 14)
const icon = service !== undefined ? service.folderIcon(path, true, 14) : builtinFolderIcon(14)
return (
<div
className={clsx(css.explorerRow, dropTarget && css.explorerRowDropTarget)}
@@ -693,7 +693,7 @@ export function FileTree(props: {
/** One directory's leading glyph for the surfaces WITHOUT a memoized row
* (the inline rename and new-folder editors). */
const dirRowIcon = (path: string, open: boolean): ReactNode =>
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)
+1 -2
View File
@@ -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<Lens>(meta.lens === 'session' ? 'session' : 'git')
@@ -278,7 +278,6 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen
<GitLens
ctx={ctx}
scope={scope}
store={store}
visible={visible}
active={lens === 'git'}
onOpenFile={onOpenFile ?? (() => { /* no-op */ })}
+2 -5
View File
@@ -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<GitLogEntry, 'hash' | 'hashFull' | 'subject'>
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<GitWorktree[]>([])
+1 -2
View File
@@ -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 <FileTypeIcon kind="folder" size={size} />
}
+1 -1
View File
@@ -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
+4 -5
View File
@@ -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)
})
})
-2
View File
@@ -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,
+1 -2
View File
@@ -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(
<GitLens scope={{ sessionId: options.sessionId, cwd: CWD }} store={createSidebarStore()} visible
<GitLens scope={{ sessionId: options.sessionId, cwd: CWD }} visible
selectedRef={null} onOpenFile={() => {}} onPreview={() => {}} />,
)
await flush()
+1 -3
View File
@@ -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) => <GitLens scope={{ sessionId, cwd: CWD }} store={store} visible
const render = (sessionId: string) => <GitLens scope={{ sessionId, cwd: CWD }} visible
selectedRef={null} onOpenFile={() => {}} onPreview={() => {}} />
const view = renderRoot(render('scm-A'))
await flush()
-2
View File
@@ -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,
-2
View File
@@ -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,