mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-23 14:33:36 +08:00
File browsing and workspace trees were treating every dot-prefixed entry as hidden, which made project files such as .env.example impossible to select through the desktop file surfaces. The fix keeps normal dotfiles and project folders visible while still hiding VCS metadata directories such as .git. Constraint: VCS internals should stay out of user-facing file trees even when dotfiles are visible Rejected: Add a UI toggle for hidden files | issue asks for file lists to include dot-prefixed project entries by default Confidence: high Scope-risk: narrow Directive: Do not reintroduce blanket dotfile filtering on filesystem browse, workspace tree, or path completion paths Tested: bun test src/server/__tests__/filesystem.test.ts src/server/__tests__/workspace-service.test.ts src/utils/suggestions/directoryCompletion.test.ts Tested: bun run check:server Not-tested: desktop browser visual smoke
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { afterEach, describe, expect, it } from 'bun:test'
|
|
import * as fs from 'fs/promises'
|
|
import * as os from 'os'
|
|
import * as path from 'path'
|
|
import { clearPathCache, getDirectoryCompletions, scanDirectory } from './directoryCompletion.js'
|
|
|
|
const cleanupDirs = new Set<string>()
|
|
|
|
afterEach(async () => {
|
|
clearPathCache()
|
|
for (const dir of cleanupDirs) {
|
|
await fs.rm(dir, { recursive: true, force: true })
|
|
}
|
|
cleanupDirs.clear()
|
|
})
|
|
|
|
describe('directory completion', () => {
|
|
it('includes dot-prefixed directories in directory scans and completions', async () => {
|
|
const fixtureDir = await fs.mkdtemp(path.join(os.tmpdir(), 'directory-completion-'))
|
|
cleanupDirs.add(fixtureDir)
|
|
|
|
await fs.mkdir(path.join(fixtureDir, '.claude'))
|
|
await fs.mkdir(path.join(fixtureDir, '.git'))
|
|
await fs.mkdir(path.join(fixtureDir, 'src'))
|
|
await fs.writeFile(path.join(fixtureDir, '.env'), 'SECRET=example')
|
|
|
|
await expect(scanDirectory(fixtureDir)).resolves.toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({ name: '.claude', type: 'directory' }),
|
|
expect.objectContaining({ name: 'src', type: 'directory' }),
|
|
]),
|
|
)
|
|
await expect(scanDirectory(fixtureDir)).resolves.not.toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({ name: '.git' }),
|
|
]),
|
|
)
|
|
|
|
const completions = await getDirectoryCompletions('./.c', { basePath: fixtureDir })
|
|
expect(completions).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({ displayText: '.claude/' }),
|
|
]),
|
|
)
|
|
expect(completions.some((completion) => completion.displayText === '.env/')).toBe(false)
|
|
})
|
|
})
|