Remove verified dead declarations (#2714)

* chore: remove verified dead declarations

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: narrow unused internal exports

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: remove newly exposed dead helpers

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: remove unused deep-link serializer

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* test: drop two tests that assert on copies of the code

mainLayoutMobileSidebarMount read MainLayout.tsx and SessionSidebar.tsx as
strings and asserted on source substrings down to exact indentation, so it
failed on formatting rather than behaviour. useProjectSessionSelection.test
reimplemented the hook's visitNodes logic inside the test file and asserted
against that copy, so it could not observe the hook at all.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* test: repair sync suites that had rotted while unrunnable

No runner executed packages/ui, so these drifted from the source unnoticed:
two imported helpers that are no longer exported, one directory-store stub
predated the session field routeMessage reads, and the WebSocket fake missed
the mandatory url-token mint plus the close event the socket wrapper reads.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* test: stop the web suite failing on timeouts and a hand-copied mock

The Git suites drive a real git binary, so the 5s default made a valid suite
fail differently per run. The gitApiHttp mock listed ~70 export names by hand
and fell behind the source; it now derives every stub from the real module,
which the added shared-UI aliases make resolvable.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* test: run every suite from one command and in CI

packages/ui (232 files) and packages/vscode (22) had no test script at all, CI
ran neither, and 9 vscode files could never run because Node cannot resolve
their extensionless TypeScript imports. Three electron files sat outside every
script list, one of them importing vitest, which that package does not depend
on. A runner gives each file its own process, since these suites keep
module-level singletons and fail by load order when sharing one.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: delete a superseded repro harness and a completed plan

The issue-2638 harness needed lsof, overrode process.platform and spawned real
servers, and nothing referenced it; event-stream/rebind.test.js now covers the
same hub-pinned-to-the-old-port behaviour. The pairing v2 plan described relay
and the pairing UI as out of scope, both of which shipped.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* docs: point at the theme tools and record the github barrel invariant

convert-vscode-theme and harmonize-theme were referenced nowhere, so the
theme-authoring reference now names them. The github barrel is loaded through
await import('./index.js') and destructured per route, which no static report
can see; documenting that is what stops the next cleanup from deleting it.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* test: repair merge drift in bridge and route-registry mocks

upstream/main gained upsertProviderConfig on bridge-system-runtime and a
PATCH scheduled-task route after this branch forked. Their test doubles
were never updated to match:
- bridge-system-runtime.test.js: add upsertProviderConfig to the
  opencodeConfig mock so the import resolves.
- sse-routes.test.js: add app.patch to the route registry stub.

---------

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
Serhii Dziupin
2026-08-13 15:30:54 +03:00
committed by GitHub
co-authored by Serhii Dziupin
parent 61533ed881
commit 86e6a2ae76
65 changed files with 238 additions and 2509 deletions
+1 -1
View File
@@ -60,4 +60,4 @@ async function modelsCommand(options = {}, action = 'show') {
process.stdout.write(formatModelsOutput(result));
}
export { modelsCommand, formatModelsOutput, formatDefaultLine, formatModelRef };
export { modelsCommand, formatModelsOutput };
@@ -39,36 +39,3 @@ export function discoverGitCredentials() {
return credentials;
}
export function getCredentialForHost(host) {
if (!fs.existsSync(GIT_CREDENTIALS_PATH)) {
return null;
}
try {
const content = fs.readFileSync(GIT_CREDENTIALS_PATH, 'utf8');
const lines = content.split('\n').filter(line => line.trim());
for (const line of lines) {
try {
const url = new URL(line.trim());
const hostname = url.hostname;
const pathname = url.pathname && url.pathname !== '/' ? url.pathname : '';
const credHost = hostname + pathname;
if (credHost === host) {
return {
username: url.username || '',
token: url.password || ''
};
}
} catch {
continue;
}
}
} catch (error) {
console.error('Failed to read .git-credentials for host lookup:', error);
}
return null;
}
@@ -7,7 +7,7 @@
## Entrypoints and structure
- `packages/web/server/lib/github/index.js`: public server entrypoint.
- `packages/web/server/lib/github/index.js`: public server entrypoint. `routes.js` loads it lazily with `await import('./index.js')` and destructures the handler it needs, so a re-export removed from here breaks a route at request time rather than at build time. Static "unused export" reports do not see these consumers.
- `packages/web/server/lib/github/routes.js`: Express route registration for `/api/github/*` endpoints.
- `packages/web/server/lib/github/auth.js`: auth storage, multi-account support, client id, scope config.
- `packages/web/server/lib/github/device-flow.js`: OAuth device flow.
@@ -111,8 +111,6 @@ const jobKey = (repoRoot, sourceKeyValue) => `${repoRoot}\0${sourceKeyValue}`;
* would imply progress where there is none. `retrying` appears only when a
* provider rejects the schema and the prompt-side fallback runs.
*/
export const GENERATION_STAGES = ['collecting', 'asking', 'retrying', 'assembling'];
const setStage = (repoRoot, sourceKeyValue, stage) => {
const job = jobs.get(jobKey(repoRoot, sourceKeyValue));
if (job) job.stage = stage;
+3
View File
@@ -17,6 +17,9 @@ const createRouteRegistry = () => {
put(path, handler) {
routes.set(`PUT ${path}`, handler);
},
patch(path, handler) {
routes.set(`PATCH ${path}`, handler);
},
delete(path, handler) {
routes.set(`DELETE ${path}`, handler);
},
+7 -69
View File
@@ -1,74 +1,12 @@
import { describe, expect, it, vi } from 'vitest';
vi.mock('@openchamber/ui/lib/gitApiHttp', () => ({
checkIsGitRepository: vi.fn(),
getGitStatus: vi.fn(),
getGitDiff: vi.fn(),
getGitFileDiff: vi.fn(),
revertGitFile: vi.fn(),
stageGitFile: vi.fn(),
stageGitFiles: vi.fn(),
unstageGitFile: vi.fn(),
unstageGitFiles: vi.fn(),
stageGitHunk: vi.fn(),
unstageGitHunk: vi.fn(),
revertGitHunk: vi.fn(),
isLinkedWorktree: vi.fn(),
getGitBranches: vi.fn(),
deleteGitBranch: vi.fn(),
deleteRemoteBranch: vi.fn(),
removeRemote: vi.fn(),
generateCommitMessage: vi.fn(),
generatePullRequestDescription: vi.fn(),
listGitWorktrees: vi.fn(),
validateGitWorktree: vi.fn(),
createGitWorktree: vi.fn(),
deleteGitWorktree: vi.fn(),
validateWorktreeDirectory: vi.fn(),
canonicalizeWorktreeState: vi.fn(),
createGitCommit: vi.fn(),
gitPush: vi.fn(),
gitPull: vi.fn(),
gitFetch: vi.fn(),
listGitStashes: vi.fn(),
countGitStashFiles: vi.fn(),
stashGitChanges: vi.fn(),
applyGitStash: vi.fn(),
popGitStash: vi.fn(),
dropGitStash: vi.fn(),
checkoutBranch: vi.fn(),
createBranch: vi.fn(),
renameBranch: vi.fn(),
getGitLog: vi.fn(),
getCommitFiles: vi.fn(),
getCurrentGitIdentity: vi.fn(),
hasLocalIdentity: vi.fn(),
setGitIdentity: vi.fn(),
getGitIdentities: vi.fn(),
createGitIdentity: vi.fn(),
updateGitIdentity: vi.fn(),
deleteGitIdentity: vi.fn(),
getRemotes: vi.fn(),
rebase: vi.fn(),
abortRebase: vi.fn(),
continueRebase: vi.fn(),
merge: vi.fn(),
abortMerge: vi.fn(),
continueMerge: vi.fn(),
stash: vi.fn(),
stashPop: vi.fn(),
getConflictDetails: vi.fn(),
checkoutCommit: vi.fn(),
cherryPick: vi.fn(),
revertCommit: vi.fn(),
resetToCommit: vi.fn(),
getCommitFileDiff: vi.fn(),
previewGitWorktree: vi.fn(),
getGitWorktreeBootstrapStatus: vi.fn(),
discoverGitCredentials: vi.fn(),
getGlobalGitIdentity: vi.fn(),
getRemoteUrl: vi.fn(),
}));
// Every export is auto-stubbed from the real module. The previous hand-written
// list of ~70 names silently fell behind the source: `getGitRangeDiff` was added
// upstream, the list was not, and the whole file failed on an unrelated change.
vi.mock('@openchamber/ui/lib/gitApiHttp', async (importOriginal) => {
const actual = await importOriginal<Record<string, unknown>>();
return Object.fromEntries(Object.keys(actual).map((name) => [name, vi.fn()]));
});
describe('createWebGitAPI', () => {
it('exposes bulk stage and unstage methods', async () => {
+24 -4
View File
@@ -1,11 +1,31 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
const here = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
resolve: {
alias: {
'bun:test': fileURLToPath(new URL('./test/bun-test-shim.ts', import.meta.url)),
'@openchamber/ui': fileURLToPath(new URL('../ui/src', import.meta.url)),
},
alias: [
{ find: 'bun:test', replacement: path.resolve(here, './test/bun-test-shim.ts') },
// The same shared-UI aliases the app build uses. Without them a test can
// reference `@openchamber/ui/...` in a mock factory but not resolve the
// real module behind it, which is what forced mocks to hand-copy export
// lists that then fell behind the source.
{ find: '@opencode-ai/sdk/v2', replacement: path.resolve(here, '../../node_modules/@opencode-ai/sdk/dist/v2/client.js') },
{ find: '@openchamber/ui', replacement: path.resolve(here, '../ui/src') },
{ find: '@web', replacement: path.resolve(here, './src') },
// Anchored to `@/` on purpose: a bare `@` prefix would also swallow
// scoped dependencies the server tests rely on, such as `@octokit/rest`.
{ find: /^@\//, replacement: `${path.resolve(here, '../ui/src')}/` },
],
},
test: {
// The Git suites drive a real `git` binary against temporary repositories.
// Those subprocess round-trips routinely pass the 5s default, and which
// cases exceed it shifts with machine load, so the default made a valid
// suite fail differently on every run.
testTimeout: 30_000,
hookTimeout: 30_000,
},
});