diff --git a/config/knip.mobile.json b/config/knip.mobile.json new file mode 100644 index 00000000000..ac35e9fc4be --- /dev/null +++ b/config/knip.mobile.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://unpkg.com/knip@5/schema.json", + "include": ["files"], + "entry": [ + "app/**/*.{js,jsx,ts,tsx}", + "host-web-app/**/*.{js,jsx,ts,tsx}", + "src/**/*.test.{ts,tsx}", + "src/**/*.{ios,android,native,web}.{js,jsx,ts,tsx}", + "src/mobile-web/disabled-page-async-storage.ts", + "src/mobile-web/disabled-page-client-context.tsx", + "src/mobile-web/disabled-page-host-store.ts", + "packages/*/src/index.ts", + "packages/*/src/**/*.{ios,android,native,web}.{js,jsx,ts,tsx}", + "plugins/*.js", + "metro.config.js", + "scripts/prepare-android-release.mjs", + "scripts/test-subscribe.ts", + "scripts/repro-terminal-colors.ts", + "scripts/repro-worktree-startup-stream.ts" + ], + "project": [ + "{app,host-web-app,src,scripts,plugins}/**/*.{js,jsx,mjs,cjs,ts,tsx}", + "packages/*/src/**/*.{js,jsx,ts,tsx}", + "*.{js,ts}" + ], + "ignoreFiles": [ + "src/accounts/use-open-mobile-accounts.ts", + "src/components/mobile-pr-url.ts", + "src/notifications/use-open-notification-route.ts", + "src/session/mobile-native-chat-message-occurrences.ts", + "src/session/use-mobile-native-chat-cancel-ask.ts", + "src/session/use-open-mobile-session.ts", + "src/tasks/use-open-mobile-tasks.ts" + ], + "ignoreExportsUsedInFile": true, + "includeEntryExports": false +} diff --git a/mobile/src/mobile-web/mobile-web-task-roundtrip-host-fixtures.ts b/mobile/src/mobile-web/mobile-web-task-roundtrip-host-fixtures.ts index 81faa1658ef..5528d716c10 100644 --- a/mobile/src/mobile-web/mobile-web-task-roundtrip-host-fixtures.ts +++ b/mobile/src/mobile-web/mobile-web-task-roundtrip-host-fixtures.ts @@ -193,50 +193,9 @@ export function taskRoundtripHostResponse(method: string): { ok: true; result: u } } } - if (method === 'github.prChecks') { - return { - ok: true, - result: [ - { - name: 'Mobile checks', - status: 'completed', - conclusion: 'success', - url: 'https://github.com/stablyai/orca/actions/runs/1' - } - ] - } - } if (method === 'github.rerunPRChecks') { return { ok: true, result: { ok: true } } } - if (method === 'github.setPRFileViewed') { - return { ok: true, result: true } - } - if (method === 'github.prFileContents') { - return { - ok: true, - result: { - original: 'before\n', - modified: 'after\n', - originalIsBinary: false, - modifiedIsBinary: false - } - } - } - if (method === 'github.addPRReviewComment') { - return { - ok: true, - result: { - ok: true, - comment: { - id: 24, - body: 'Inline comment', - path: 'src/file.ts', - line: 7 - } - } - } - } if (method === 'gitlab.workItemDetails') { return { ok: true, diff --git a/mobile/src/session/mobile-file-tap-open.test.ts b/mobile/src/session/mobile-file-tap-open.test.ts index d0590bad766..a25e7ba28cd 100644 --- a/mobile/src/session/mobile-file-tap-open.test.ts +++ b/mobile/src/session/mobile-file-tap-open.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest' import type { HostSessionTerminalFileTarget } from './host-session-terminal-file-operations' -import { openMobileTerminalFileTap } from './mobile-terminal-file-tap-open' +import { openMobileFileTap as openMobileTerminalFileTap } from './mobile-file-tap-open' function createOperations(targets: (HostSessionTerminalFileTarget | null)[]) { return { diff --git a/mobile/src/session/mobile-terminal-file-tap-open.ts b/mobile/src/session/mobile-terminal-file-tap-open.ts deleted file mode 100644 index f29629ebfb2..00000000000 --- a/mobile/src/session/mobile-terminal-file-tap-open.ts +++ /dev/null @@ -1 +0,0 @@ -export { openMobileFileTap as openMobileTerminalFileTap } from './mobile-file-tap-open' diff --git a/package.json b/package.json index 2c85af27f86..cef3b81f146 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "audit:code-quality:type-aware": "oxlint --type-aware --config config/oxlint-code-quality-type-aware.json src config tests --deny-warnings", "audit:react-doctor": "pnpm dlx react-doctor@0.9.1 . --yes --no-supply-chain --no-telemetry --blocking none", "audit:dead-code": "pnpm dlx knip@5.88.1 --config config/knip.json", + "audit:dead-code:mobile": "pnpm dlx knip@5.88.1 --directory mobile --config ../config/knip.mobile.json", "check:code-quality:changed": "node config/scripts/check-changed-code-quality.mjs", "check:react-doctor:changed": "node config/scripts/check-react-doctor-changed.mjs", "check:zustand-selector-fanout": "node config/scripts/zustand-selector-fanout-benchmark.mjs --check", diff --git a/src/main/providers/filesystem-path-listing-provider.ts b/src/main/providers/filesystem-path-listing-provider.ts deleted file mode 100644 index 951fe981166..00000000000 --- a/src/main/providers/filesystem-path-listing-provider.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type FilesystemPathListingProvider = { - listFiles( - rootPath: string, - options?: { excludePaths?: string[]; signal?: AbortSignal; maxResults?: number } - ): Promise - listMarkdownDocuments?(rootPath: string): Promise -} diff --git a/src/main/providers/provider-registry-types.ts b/src/main/providers/provider-registry-types.ts deleted file mode 100644 index 57e4f851ef9..00000000000 --- a/src/main/providers/provider-registry-types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { IFilesystemProvider, IGitProvider, IPtyProvider } from './types' - -/** Routes operations by connectionId; null/undefined selects the local provider. */ -export type IProviderRegistry = { - getPtyProvider(connectionId: string | null | undefined): IPtyProvider - getFilesystemProvider(connectionId: string | null | undefined): IFilesystemProvider - getGitProvider(connectionId: string | null | undefined): IGitProvider -} diff --git a/src/main/providers/ssh-filesystem-terminal-artifact-writer.ts b/src/main/providers/ssh-filesystem-terminal-artifact-writer.ts deleted file mode 100644 index 6feb9b438f9..00000000000 --- a/src/main/providers/ssh-filesystem-terminal-artifact-writer.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { SshChannelMultiplexer } from '../ssh/ssh-channel-multiplexer' -import { isMethodNotFoundError } from '../ssh/ssh-filesystem-stream-reader' -import type { FileStat, TerminalArtifactAccessOptions } from './types' - -export async function writeSshTerminalArtifact( - mux: SshChannelMultiplexer, - filePath: string, - content: string, - options: TerminalArtifactAccessOptions -): Promise { - let result: { stat?: FileStat } - try { - result = (await mux.request('fs.writeTerminalArtifact', { - filePath, - content, - expectedRealPath: options.expectedRealPath, - expectedStatIdentity: options.expectedStatIdentity, - maxBytes: options.maxBytes - })) as { stat?: FileStat } - } catch (error) { - if (isMethodNotFoundError(error)) { - throw new Error( - 'Remote terminal artifact access is unavailable. Reconnect the SSH target before retrying.' - ) - } - throw error - } - if (!result.stat) { - throw new Error('terminal_file_grant_stale') - } - return result.stat -} diff --git a/src/mobile-web/src/mobile-web-file-edit-content.ts b/src/mobile-web/src/mobile-web-file-edit-content.ts index f105887de8f..6f1ec07c398 100644 --- a/src/mobile-web/src/mobile-web-file-edit-content.ts +++ b/src/mobile-web/src/mobile-web-file-edit-content.ts @@ -1,26 +1,4 @@ import { sha256 } from '@noble/hashes/sha256' -import { MOBILE_WEB_FILE_EDIT_MAX_BYTES } from '../../shared/mobile-web/file-edit-contract' -import { MobileWebBridgeClientError } from './mobile-web-bridge-client-error' - -export function encodeMobileWebFileEdit(content: string): { - contentBase64: string - revision: string - byteLength: number -} { - const bytes = new TextEncoder().encode(content) - if (bytes.byteLength > MOBILE_WEB_FILE_EDIT_MAX_BYTES) { - throw new MobileWebBridgeClientError('too_large', false) - } - let binary = '' - for (let offset = 0; offset < bytes.byteLength; offset += 32 * 1024) { - binary += String.fromCharCode(...bytes.subarray(offset, offset + 32 * 1024)) - } - return { - contentBase64: btoa(binary), - revision: mobileWebFileRevision(bytes), - byteLength: bytes.byteLength - } -} export function mobileWebFileRevision(bytes: Uint8Array): string { return Array.from(sha256(bytes), (value) => value.toString(16).padStart(2, '0')).join('') diff --git a/src/shared/mobile-web/source-control-mutation-contract.ts b/src/shared/mobile-web/source-control-mutation-contract.ts index 1b7ddc945c1..c3e2d8f1266 100644 --- a/src/shared/mobile-web/source-control-mutation-contract.ts +++ b/src/shared/mobile-web/source-control-mutation-contract.ts @@ -125,6 +125,3 @@ function validateUniquePaths( paths.add(entry.relativePath) }) } - -export type MobileWebSourceControlMutationStatus = MobileWebSourceControlMutationEntry['status'] -export type MobileWebSourceControlMutationArea = MobileWebSourceControlMutationEntry['area']