mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
fixup: address CodeRabbit review on PR #386
Twelve actionable items (7 Major + 5 Minor) from the CodeRabbit review on claude-code-best/claude-code#386: - docs/internals/autonomy-jira.md: typo "due input close" → "due to input close". - src/utils/autonomyRuns.ts: - selectPersistedAutonomyRuns no longer evicts active (queued/running) runs when the combined list exceeds AUTONOMY_RUNS_MAX. Active runs are kept in full and the inactive history is capped to the remaining budget so persisted ownership for live work survives. - isValidOwnerProcessId now allows pid <= 4_194_304 so a live run owned by the maximum Linux PID is not treated as stale. - src/utils/autonomyAuthority.ts: maskCodeFencedLines tracks the active fence length and only closes the fence when a same-character run of equal-or- greater length appears with no trailing content, so a nested ```yaml inside an outer ```` block no longer leaks fake `tasks:` entries into the parser. - src/cli/print.ts: late-shutdown branches in the cron and scheduled-task paths now call cancelQueuedAutonomyCommands({ commands: [command] }) instead of markAutonomyRunCancelled(...). Updating run state alone left the queue-side record orphaned for resume/recovery. - src/utils/processUserInput/processSlashCommand.tsx: scheduled-task-result notification is enqueued before finalizeAutonomyRunCompleted (which queues follow-up autonomy commands) so both at priority: 'later' land in order and the next autonomy step can not run before the worker's output is observed. - src/screens/REPL.tsx + src/utils/handlePromptSubmit.ts: - onQuery now returns Promise<boolean>: false from the concurrent-guard skip path, true otherwise. Other call sites use `void onQuery(...)` and are unaffected. handlePromptSubmit's onQuery prop type matches. - The autonomy-prompt callsite captures the executed flag, finalizes claim.claimedCommands as { type: 'completed' } only when onQuery actually ran, and runs the completed-finalize in its own try/catch so a failure there does not propagate into the outer catch and trigger a second finalize as { type: 'failed' } for the same commands. - Removed the unsafe `command.value as string` cast; createUserMessage already accepts `string | ContentBlockParam[]`. - createUserMessage mock in src/__tests__/handlePromptSubmit.test.ts now matches the new Promise<boolean> shape. - packages/builtin-tools/src/tools/RemoteTriggerTool/__tests__/ RemoteTriggerTool.test.ts: - Inline auth mock replaced with the shared tests/mocks/auth (added). - The full mock of src/constants/oauth.js is replaced by a narrow side-effect-only mock that overrides the env-reading helpers (getOauthConfig, fileSuffixForOauthConfig, MCP_CLIENT_METADATA_URL) and delegates pure data exports to the real module. - tests/integration/dependency-overrides.test.ts: - mermaid does not export `./package.json` in its exports map, so require.resolve('mermaid/package.json') throws ERR_PACKAGE_PATH_NOT_EXPORTED in runtimes that honor exports semantics. The test now resolves the package entry and walks up to the package root via a small findPackageJson helper. - readFileSync from node:fs is replaced with `await Bun.file(...).text()` to match the project's Bun-API requirement. Validation: - bun run typecheck (clean). - bun test → 3996 pass / 0 fail across 305 test files. Targets PRs: - amDosion/claude-code-bast#8 (fork-internal review) - claude-code-best/claude-code#386 (upstream review, same head branch)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test'
|
||||
import { authMock } from '../../../../../../tests/mocks/auth'
|
||||
|
||||
let requestStatus = 200
|
||||
const auditRecords: Record<string, unknown>[] = []
|
||||
@@ -12,11 +13,7 @@ mock.module('axios', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
mock.module('src/utils/auth.js', () => ({
|
||||
checkAndRefreshOAuthTokenIfNeeded: async () => {},
|
||||
getClaudeAIOAuthTokens: () => ({ accessToken: 'token' }),
|
||||
isClaudeAISubscriber: () => true,
|
||||
}))
|
||||
mock.module('src/utils/auth.js', authMock)
|
||||
|
||||
mock.module('src/services/oauth/client.js', () => ({
|
||||
getOrganizationUUID: async () => 'org',
|
||||
@@ -30,17 +27,19 @@ mock.module('src/services/policyLimits/index.js', () => ({
|
||||
isPolicyAllowed: () => true,
|
||||
}))
|
||||
|
||||
mock.module('src/constants/oauth.js', () => ({
|
||||
ALL_OAUTH_SCOPES: ['user:profile', 'user:inference'],
|
||||
CLAUDE_AI_INFERENCE_SCOPE: 'user:inference',
|
||||
CLAUDE_AI_OAUTH_SCOPES: ['user:profile', 'user:inference'],
|
||||
CLAUDE_AI_PROFILE_SCOPE: 'user:profile',
|
||||
CONSOLE_OAUTH_SCOPES: ['org:create_api_key', 'user:profile'],
|
||||
MCP_CLIENT_METADATA_URL: 'https://example.test/oauth/metadata',
|
||||
OAUTH_BETA_HEADER: 'oauth-test',
|
||||
fileSuffixForOauthConfig: () => '',
|
||||
getOauthConfig: () => ({ BASE_API_URL: 'https://example.test' }),
|
||||
}))
|
||||
// Narrow mock for the side-effectful entries in `src/constants/oauth.js`.
|
||||
// Pure data exports (ALL_OAUTH_SCOPES, CLAUDE_AI_*_SCOPE, etc.) come from
|
||||
// the real module and are not mocked, per the test policy that constants
|
||||
// modules without side effects should not be replaced wholesale.
|
||||
mock.module('src/constants/oauth.js', () => {
|
||||
const actual = require('../../../../../../src/constants/oauth.js')
|
||||
return {
|
||||
...actual,
|
||||
fileSuffixForOauthConfig: () => '',
|
||||
getOauthConfig: () => ({ BASE_API_URL: 'https://example.test' }),
|
||||
MCP_CLIENT_METADATA_URL: 'https://example.test/oauth/metadata',
|
||||
}
|
||||
})
|
||||
|
||||
mock.module('src/utils/remoteTriggerAudit.js', () => ({
|
||||
appendRemoteTriggerAuditRecord: async (
|
||||
|
||||
Reference in New Issue
Block a user