mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 16:02:55 +00:00
* chore(lint): upgrade oxlint to 1.71 and enable 7 new rules Upgrade oxlint 1.67.0 -> 1.71.0 (1.72 was blocked by the repo's 3-day minimum-release-age supply-chain guard; nothing here needs it). The bump is a no-op on the existing config. Enable 3 error rules (backlog autofixed to zero in this commit) and 4 warn rules (surface signal without gating CI): error (autofixed, behavior-preserving): - unicorn/prefer-node-protocol (~1531 sites: bare builtin -> node:) - typescript/no-import-type-side-effects (~36: all-inline-type -> import type) - unicorn/no-array-reverse (19: copy-then-reverse -> toReversed) warn (real signal, current fires are test-only/correct): - unicorn/no-array-fill-with-reference-type (aliasing footgun guard) - typescript/no-unsafe-function-type (bans bare Function type) - unicorn/prefer-array-flat-map (map().flat() -> flatMap()) - unicorn/prefer-regexp-test (.match() in bool ctx -> .test()) mobile/.oxlintrc.json extends root, so it inherits all 7; the autofix ran from root and covered mobile/ too. Verification (all green): oxlint 0 errors (root+mobile+aux configs), oxfmt clean, typecheck (node+cli+web), vitest 22795 passed / 0 failed, builds (electron-vite + web + cli) succeed. node: rewrites confirmed to skip embedded SSH/CLI string payloads (AST-only); all toReversed sites verified to operate on fresh copies or write-once locals. * chore(lint): bump mobile oxlint to 1.71 so inherited rules parse mobile/ is a standalone pnpm project pinning its own oxlint@1.67, which lacks unicorn/no-array-fill-with-reference-type (needs >=1.70). Since mobile/.oxlintrc.json extends the root config, mobile CI's 'cd mobile && oxlint' failed to parse the new rule. Bump mobile to match root (1.71). Verified in mobile/: oxlint 0 errors, oxfmt --check clean, tsc --noEmit pass, vitest 978 passed / 0 failed. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
147 lines
5.2 KiB
TypeScript
147 lines
5.2 KiB
TypeScript
import { execFileSync } from 'node:child_process'
|
|
import { mkdtempSync, realpathSync, rmSync } from 'node:fs'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { test, expect } from './helpers/orca-app'
|
|
|
|
test.describe('Workspace Space git status checks', () => {
|
|
test('checks every scanned deletable row, including rows after the first 50', async ({
|
|
orcaPage,
|
|
testRepoPath
|
|
}) => {
|
|
const worktreeParent = mkdtempSync(path.join(os.tmpdir(), 'orca-space-git-status-'))
|
|
const worktreePaths = Array.from({ length: 60 }, (_, index) =>
|
|
path.join(worktreeParent, `worktree-${index}`)
|
|
)
|
|
|
|
try {
|
|
for (const worktreePath of worktreePaths) {
|
|
execFileSync('git', ['worktree', 'add', '--detach', worktreePath, 'HEAD'], {
|
|
cwd: testRepoPath,
|
|
stdio: 'pipe'
|
|
})
|
|
}
|
|
const registeredWorktreePaths = worktreePaths.map((worktreePath) =>
|
|
realpathSync(worktreePath)
|
|
)
|
|
|
|
await orcaPage.evaluate(
|
|
async ({ testRepoPath, worktreePaths }) => {
|
|
const store = window.__store
|
|
if (!store) {
|
|
throw new Error('Expected e2e store to be exposed')
|
|
}
|
|
|
|
const initialState = store.getState()
|
|
const repo = initialState.repos.find((item) => item.path === testRepoPath)
|
|
if (!repo) {
|
|
throw new Error('Expected test repo to be loaded')
|
|
}
|
|
await initialState.fetchWorktrees(repo.id)
|
|
await window.api.git.status({ worktreePath: worktreePaths[0] })
|
|
|
|
const state = store.getState()
|
|
const expectedPaths = new Set(worktreePaths)
|
|
const worktrees = (state.worktreesByRepo[repo.id] ?? []).filter((worktree) =>
|
|
expectedPaths.has(worktree.path)
|
|
)
|
|
if (worktrees.length !== worktreePaths.length) {
|
|
throw new Error(
|
|
`Expected ${worktreePaths.length} registered worktrees, got ${
|
|
worktrees.length
|
|
} from ${(state.worktreesByRepo[repo.id] ?? []).length}: ${(
|
|
state.worktreesByRepo[repo.id] ?? []
|
|
)
|
|
.slice(0, 5)
|
|
.map((worktree) => worktree.path)
|
|
.join(', ')}`
|
|
)
|
|
}
|
|
const rows = worktrees.map((worktree, index) => ({
|
|
worktreeId: worktree.id,
|
|
repoId: repo.id,
|
|
repoDisplayName: repo.displayName,
|
|
repoPath: testRepoPath,
|
|
displayName: worktree.displayName,
|
|
path: worktree.path,
|
|
branch: worktree.branch,
|
|
isMainWorktree: false,
|
|
isRemote: false,
|
|
isSparse: worktree.isSparse,
|
|
canDelete: true,
|
|
lastActivityAt: worktree.lastActivityAt,
|
|
status: 'ok' as const,
|
|
error: null,
|
|
scannedAt: Date.now(),
|
|
sizeBytes: 1000 + index,
|
|
reclaimableBytes: 1000 + index,
|
|
skippedEntryCount: 0,
|
|
topLevelItems: [],
|
|
omittedTopLevelItemCount: 0,
|
|
omittedTopLevelSizeBytes: 0
|
|
}))
|
|
|
|
store.setState({
|
|
gitStatusByWorktree: {},
|
|
workspaceSpaceAnalysis: {
|
|
scannedAt: Date.now(),
|
|
totalSizeBytes: rows.reduce((sum, row) => sum + row.sizeBytes, 0),
|
|
reclaimableBytes: rows.reduce((sum, row) => sum + row.reclaimableBytes, 0),
|
|
worktreeCount: rows.length,
|
|
scannedWorktreeCount: rows.length,
|
|
unavailableWorktreeCount: 0,
|
|
repos: [
|
|
{
|
|
repoId: repo.id,
|
|
displayName: repo.displayName,
|
|
path: repo.path,
|
|
isRemote: false,
|
|
worktreeCount: rows.length,
|
|
scannedWorktreeCount: rows.length,
|
|
unavailableWorktreeCount: 0,
|
|
totalSizeBytes: rows.reduce((sum, row) => sum + row.sizeBytes, 0),
|
|
reclaimableBytes: rows.reduce((sum, row) => sum + row.reclaimableBytes, 0),
|
|
error: null
|
|
}
|
|
],
|
|
worktrees: rows
|
|
}
|
|
})
|
|
store.getState().openSpacePage()
|
|
},
|
|
{ testRepoPath, worktreePaths: registeredWorktreePaths }
|
|
)
|
|
|
|
await expect
|
|
.poll(
|
|
() =>
|
|
orcaPage.evaluate(() => {
|
|
const state = window.__store?.getState()
|
|
if (!state?.workspaceSpaceAnalysis) {
|
|
return 60
|
|
}
|
|
return state.workspaceSpaceAnalysis.worktrees.filter(
|
|
(row) => state.gitStatusByWorktree[row.worktreeId] === undefined
|
|
).length
|
|
}),
|
|
{ timeout: 30_000 }
|
|
)
|
|
.toBe(0)
|
|
|
|
await expect(orcaPage.getByText('Keep: git not checked')).toHaveCount(0)
|
|
} finally {
|
|
for (const worktreePath of worktreePaths) {
|
|
try {
|
|
execFileSync('git', ['worktree', 'remove', '--force', worktreePath], {
|
|
cwd: testRepoPath,
|
|
stdio: 'pipe'
|
|
})
|
|
} catch {
|
|
// Best effort cleanup; the fixture removes the source repo after the test.
|
|
}
|
|
}
|
|
rmSync(worktreeParent, { recursive: true, force: true })
|
|
}
|
|
})
|
|
})
|