Skip to content

fix(typecheck): replace dead-code literal comparisons with isAntEmployee()#1512

Merged
kevincodex1 merged 3 commits into
Gitlawb:mainfrom
chioarub:pr-isantemployee
Jun 9, 2026
Merged

fix(typecheck): replace dead-code literal comparisons with isAntEmployee()#1512
kevincodex1 merged 3 commits into
Gitlawb:mainfrom
chioarub:pr-isantemployee

Conversation

@chioarub

@chioarub chioarub commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Refs #1486.

Replaces all "external" === 'ant' and "external" !== 'ant' literal comparisons with isAntEmployee() and !isAntEmployee() respectively, eliminating 90 TS2367 "unintentional comparison" errors across 27 files.

Additionally, uses the IS_ANT_EMPLOYEE boolean constant (instead of isAntEmployee()) at all sites that gate dynamic import() / require() calls of ant-internal modules that do not exist in the external build. This ensures the bundler can statically evaluate the branch condition and dead-code-eliminate those calls.

What changed

Phase 1: Replace "external" === 'ant' literals with isAntEmployee()

Each "external" === 'ant' (always false) → isAntEmployee() (always returns false)
Each "external" !== 'ant' (always true) → !isAntEmployee() (always returns true)

Added import { isAntEmployee } from '.../utils/buildConfig.js' to all 27 affected files.

Phase 2: Use IS_ANT_EMPLOYEE for dynamic import/require guards

At all sites where isAntEmployee() guards a dynamic import() or require() call on an ant-internal module that doesn't exist in OpenClaude, replaced isAntEmployee() with the IS_ANT_EMPLOYEE boolean constant (false as const). The build-time source transform then replaces IS_ANT_EMPLOYEE with false, giving the bundler a concrete literal for DCE.

Affected guard sites in main.tsx (8 locations):

  • eventLoopStallDetector.js, sdkHeapDumpMonitor.js, sessionDataUploader.js, ccshareResume.js
  • src/cli/up.js, src/cli/rollback.js, ./cli/handlers/ant.js (3 commands)

Affected guard sites in REPL.tsx (5 locations):

  • useFrustrationDetection.js, useAntOrgWarningNotification.js
  • AntModelSwitchCallout.js (2 bindings), UndercoverAutoCallout.js

Phase 3: Build-time transform

Extended the featureFlagPreprocessPlugin in scripts/build.ts to:

  1. Replace isAntEmployee() calls with false (mirroring feature('FLAG') replacement)
  2. Replace IS_ANT_EMPLOYEE references with false
  3. Clean up resulting dead imports (import { false, isAntEmployee }import { isAntEmployee }) and exports (export const false = false as const → removed)

Also exported IS_ANT_EMPLOYEE = false as const from buildConfig.ts as a named constant for documentation and call-site intent, with isAntEmployee() kept as a convenience wrapper.

Files changed

Phase 1 (27 files): buddy/useBuddyNotification.tsx, commands/mcp/mcp.tsx, commands/terminalSetup/terminalSetup.tsx, commands/thinkback/thinkback.tsx, commands/ultraplan.tsx, components/ (DevBar, FeedbackSurvey, LogoV2, MemoryUsageIndicator, MessageSelector, NativeAutoUpdater, PromptInput, Settings/Config, Stats, agents/ToolSelector, messages/AttachmentMessage, tasks/taskStatusUtils), main.tsx, screens/REPL.tsx, tools/ (AgentTool, TaskOutputTool, TaskStopTool), utils/ (autoRunIssue, processUserInput/processSlashCommand).

Phase 2 (2 files): main.tsx, screens/REPL.tsx

Phase 3 (2 files): scripts/build.ts, src/utils/buildConfig.ts

Why

The Anthropic internal build replaces process.env.USER_TYPE with the string "external" at build time, and dead-code elimination then strips "external" === 'ant' branches. In the OpenClaude fork, some files had already been pre-substituted with the "external" literal, leaving TypeScript to see an impossible comparison that always evaluates to false.

isAntEmployee() is the semantically correct replacement — it communicates intent and is always false. However, because it's a runtime function call, Bun's bundler cannot evaluate it at build time, so import() / require() calls inside if (isAntEmployee()) branches were still resolved — causing build failures for modules that only exist in the internal build (sessionDataUploader, cli/up, cli/rollback, etc.).

The fix uses IS_ANT_EMPLOYEE (a false as const boolean) for import/require gates, which the bundler's source transform replaces with false for DCE. Runtime-only checks (data filtering, conditional logic) continue using isAntEmployee() for readability.

Not touched: ~273 process.env.USER_TYPE === 'ant' comparisons remain across other files. These are a separate build-time substitution pattern that should be addressed in a follow-up PR.

Validation

  • git diff --check — passed
  • bun run typecheck — zero new TS2367 errors; pre-existing errors unchanged
  • bun run scripts/build.ts — succeeds; all ant-only imports eliminated from bundle
  • bun test src/utils/buildConfig.test.ts — 2/2 pass
  • No isAntEmployee(), IS_ANT_EMPLOYEE, or ant-only module references remain in dist/cli.mjs
  • All dynamic import/require gates use IS_ANT_EMPLOYEE; all runtime logic uses isAntEmployee()
  • Build-time transform correctly cleans up dead imports and exports
  • Zero behavioral change — both isAntEmployee() and IS_ANT_EMPLOYEE evaluate to false

Summary by CodeRabbit

  • New Features

    • Buddy availability clarified: teaser shown Apr 1–7, 2026; live mode enabled from April 2026 onward.
  • Refactor

    • Centralized employee-detection across the app, affecting visibility/availability of internal-only features, dev tools and commands (e.g., DevBar, memory indicator, updater warning, task/tmux footers, Ultraplan and related commands).
    • No other user-facing behavior or UI surfaces were changed.

…isAntEmployee()

The build system replaces process.env.USER_TYPE with the string literal
'external' at build time. Dead-code elimination then removes branches
where 'external' === 'ant'. But TypeScript sees these as impossible
comparisons (TS2367) because the narrowed literal type 'external'
never equals 'ant', producing 90 type errors across 27 files.

Replace all 'external === 'ant'' with isAntEmployee() and
'external !== 'ant'' with !isAntEmployee(). The function already
exists in src/utils/buildConfig.ts and always returns false, so this
is a behavioral no-op that makes the intent explicit and type-safe.

The process.env.USER_TYPE === 'ant' pattern in other files is not
touched; it will be addressed in a follow-up.

Refs: Gitlawb#1486
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 076959e9-af10-486b-a259-05bcb7ce1fb3

📥 Commits

Reviewing files that changed from the base of the PR and between 13b07d6 and c13fc33.

📒 Files selected for processing (3)
  • scripts/build.ts
  • src/main.tsx
  • src/screens/REPL.tsx
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • scripts/build.ts
  • src/screens/REPL.tsx
  • src/main.tsx
{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}

⚙️ CodeRabbit configuration file

{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}: Review install, launcher, build, packaging, startup, and entrypoint changes for cross-platform compatibility, tracked-source rewrites, env/config precedence, and release safety. Block on changes that can break Windows/macOS/Linux startup or publish unexpected artifacts.

Files:

  • scripts/build.ts
  • src/main.tsx
🧠 Learnings (1)
📚 Learning: 2026-06-03T16:06:34.975Z
Learnt from: beardthelion
Repo: Gitlawb/openclaude PR: 1407
File: scripts/build.ts:990-995
Timestamp: 2026-06-03T16:06:34.975Z
Learning: In Bun's bundler output, every virtual/namespaced module (e.g. those resolved via `build.onResolve` returning a custom `namespace`) is prefixed in the bundle with a boundary comment of the form `// <namespace>:<resolved-path>`. This means that in `scripts/build.ts`, the regex `bundleText.matchAll(/\/\/\s*missing-module-stub:(\S+)/g)` correctly finds all `missing-module-stub`-namespaced modules in `dist/cli.mjs` without requiring the `onLoad` handler to emit any marker comment itself — Bun emits those automatically. Adding a duplicate `// missing-module-stub:${args.path}` line in the loader stub would be redundant.

Applied to files:

  • src/main.tsx
🔇 Additional comments (2)
scripts/build.ts (1)

98-105: ⚡ Quick win

Broadened IS_ANT_EMPLOYEE cleanup isn’t needed for the current codebase.
A scan of src/**/*.ts(x) applying the existing rewrites found no surviving import { ... false ... } / export { ... false ... } / export const false ..., so the two-specifier cleanup (and dead export removal) already matches all live usage patterns.

src/screens/REPL.tsx (1)

109-115: LGTM!

Also applies to: 231-233, 305-305


📝 Walkthrough

Walkthrough

Replace many ad-hoc "external" === 'ant' checks with a centralized isAntEmployee() predicate and a build-time IS_ANT_EMPLOYEE constant across startup, CLI, commands, tools, UI components, utilities, and the build plugin.

Changes

Ant employee feature gating refactor

Layer / File(s) Summary
Main entry point and CLI initialization gating
src/main.tsx
Centralize Ant-only gating for startup behaviors (debugging exit, migrations, monitors), internal CLI commands/options, telemetry enrichment, and feature initialization using isAntEmployee() / IS_ANT_EMPLOYEE.
REPL screen conditional features and rendering
src/screens/REPL.tsx
Switch REPL conditional imports, hooks, callouts, tungsten monitor, DevBar, API metrics, plan verification, and internal-only UI to isAntEmployee()/IS_ANT_EMPLOYEE guards.
PromptInput footer and related UI gating
src/components/PromptInput/*, src/components/PromptInput/PromptInputFooter*.tsx, src/components/Settings/Config.tsx
Gate tmux/tungsten footers, tasks/coordinator panels, footer keybindings, and settings display (Speculative execution) using isAntEmployee().
Commands and tools gating
src/commands/*, src/tools/*
Gate MCP routing, terminal setup completions, marketplace selection, Ultraplan availability, AgentTool isolation and permission routing, TaskOutput/TaskStop tool behavior, and related UI via isAntEmployee().
Utilities and miscellaneous component gating
src/buddy/*, src/components/*, src/utils/*
Replace tenant/build string checks in buddy notifications, memory-survey prompts, feed parsing, memory/stats UIs, restore options, attachment hints, task footer filtering, auto-run policy, and slash-command telemetry with isAntEmployee().
Build-time preprocessing and buildConfig
scripts/build.ts, src/utils/buildConfig.ts
Export IS_ANT_EMPLOYEE = false, make isAntEmployee() return it (deprecated), and update the build preprocessing plugin to inline isAntEmployee()/IS_ANT_EMPLOYEE to false during bundling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Suggested reviewers

  • jatmn
  • kevincodex1
🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing dead-code literal comparisons with isAntEmployee() across 27 files to fix TS2367 errors.
Description check ✅ Passed The description fully covers all required template sections with clear details on what changed, why, impact, testing, and validation results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Risk Surface Disclosed ✅ Passed PR discloses risk surfaces: auth/network, startup, permissions, MCP, build. All changes refactor existing checks with identical external behavior; no blockers.
No Hidden Policy Change ✅ Passed PR replaces "external"==='ant' (always false) with isAntEmployee() (always false). No policy, telemetry, permission, routing changes; purely code quality refactoring.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

…r DCE

The bundler cannot dead-code-eliminate branches guarded by isAntEmployee()
because it's an opaque function call. Extend the feature-flag preprocess
plugin to also replace isAntEmployee() with false during bundling, so
dynamic import() and require() calls gated behind ant-employee checks
are eliminated from the external build.

Also export IS_ANT_EMPLOYEE as a named constant for call-site readability
and documentation, with the function kept as a convenience wrapper.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main.tsx`:
- Line 3026: The dynamic imports guarded by the runtime isAntEmployee() (e.g.,
const sessionUploaderPromise = isAntEmployee() ?
import('./utils/sessionDataUploader.js') : null) cause bundlers to attempt
resolving non-existent ant-only modules; introduce an exported compile-time
boolean flag (e.g., export const IS_ANT_EMPLOYEE = false) and change guards to
use that flag for all ant-only dynamic imports/commands (sessionUploaderPromise
and the cli imports like 'src/cli/up.js' and 'src/cli/rollback.js') so the
bundler can prune those branches, while keeping isAntEmployee() for any real
runtime checks that remain. Ensure you export IS_ANT_EMPLOYEE from a central
config file and replace occurrences of isAntEmployee() in import guards with
IS_ANT_EMPLOYEE, leaving isAntEmployee() intact for runtime logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7d79e2b7-2c2f-4356-853f-d56dd902a682

📥 Commits

Reviewing files that changed from the base of the PR and between 343cd1a and 2513c3f.

📒 Files selected for processing (27)
  • src/buddy/useBuddyNotification.tsx
  • src/commands/mcp/mcp.tsx
  • src/commands/terminalSetup/terminalSetup.tsx
  • src/commands/thinkback/thinkback.tsx
  • src/commands/ultraplan.tsx
  • src/components/DevBar.tsx
  • src/components/FeedbackSurvey/useMemorySurvey.tsx
  • src/components/LogoV2/feedConfigs.tsx
  • src/components/MemoryUsageIndicator.tsx
  • src/components/MessageSelector.tsx
  • src/components/NativeAutoUpdater.tsx
  • src/components/PromptInput/PromptInput.tsx
  • src/components/PromptInput/PromptInputFooter.tsx
  • src/components/PromptInput/PromptInputFooterLeftSide.tsx
  • src/components/Settings/Config.tsx
  • src/components/Stats.tsx
  • src/components/agents/ToolSelector.tsx
  • src/components/messages/AttachmentMessage.tsx
  • src/components/tasks/taskStatusUtils.tsx
  • src/main.tsx
  • src/screens/REPL.tsx
  • src/tools/AgentTool/AgentTool.tsx
  • src/tools/AgentTool/UI.tsx
  • src/tools/TaskOutputTool/TaskOutputTool.tsx
  • src/tools/TaskStopTool/UI.tsx
  • src/utils/autoRunIssue.tsx
  • src/utils/processUserInput/processSlashCommand.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/components/tasks/taskStatusUtils.tsx
  • src/components/MemoryUsageIndicator.tsx
  • src/commands/terminalSetup/terminalSetup.tsx
  • src/components/LogoV2/feedConfigs.tsx
  • src/components/DevBar.tsx
  • src/components/NativeAutoUpdater.tsx
  • src/components/agents/ToolSelector.tsx
  • src/commands/mcp/mcp.tsx
  • src/commands/thinkback/thinkback.tsx
  • src/components/FeedbackSurvey/useMemorySurvey.tsx
  • src/tools/TaskOutputTool/TaskOutputTool.tsx
  • src/commands/ultraplan.tsx
  • src/tools/TaskStopTool/UI.tsx
  • src/components/messages/AttachmentMessage.tsx
  • src/components/PromptInput/PromptInputFooter.tsx
  • src/tools/AgentTool/UI.tsx
  • src/components/Stats.tsx
  • src/utils/autoRunIssue.tsx
  • src/buddy/useBuddyNotification.tsx
  • src/components/PromptInput/PromptInputFooterLeftSide.tsx
  • src/tools/AgentTool/AgentTool.tsx
  • src/components/PromptInput/PromptInput.tsx
  • src/components/Settings/Config.tsx
  • src/utils/processUserInput/processSlashCommand.tsx
  • src/components/MessageSelector.tsx
  • src/screens/REPL.tsx
  • src/main.tsx
src/{components/permissions,utils/permissions,hooks/toolPermission,tools,entrypoints/sdk}/**

⚙️ CodeRabbit configuration file

src/{components/permissions,utils/permissions,hooks/toolPermission,tools,entrypoints/sdk}/**: Review permission prompts, auto-allow logic, sandbox behavior, SDK permission schemas, shell/PowerShell execution, and background execution paths as security-sensitive. Block on bypasses, unclear trust boundaries, unsafe path handling, missing user visibility, or changes that broaden allowed behavior without an explicit maintainer decision.

Files:

  • src/tools/TaskOutputTool/TaskOutputTool.tsx
  • src/tools/TaskStopTool/UI.tsx
  • src/tools/AgentTool/UI.tsx
  • src/tools/AgentTool/AgentTool.tsx
{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}

⚙️ CodeRabbit configuration file

{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}: Review install, launcher, build, packaging, startup, and entrypoint changes for cross-platform compatibility, tracked-source rewrites, env/config precedence, and release safety. Block on changes that can break Windows/macOS/Linux startup or publish unexpected artifacts.

Files:

  • src/main.tsx
🪛 GitHub Actions: PR Checks / 1_smoke-and-tests.txt
src/main.tsx

[error] 3025-3025: Build failed: Bun could not resolve "./utils/sessionDataUploader.js". Error at /home/runner/work/openclaude/openclaude/src/main.tsx:3025:61.


[error] 4352-4352: Build failed: Bun could not resolve "src/cli/up.js" (maybe you need to run "bun install"). Error at /home/runner/work/openclaude/openclaude/src/main.tsx:4352:24.


[error] 4367-4367: Build failed: Bun could not resolve "src/cli/rollback.js" (maybe you need to run "bun install"). Error at /home/runner/work/openclaude/openclaude/src/main.tsx:4367:24.

🪛 GitHub Actions: PR Checks / smoke-and-tests
src/main.tsx

[error] 3025-3025: Bundling failed: Could not resolve "./utils/sessionDataUploader.js" (import in main.tsx).


[error] 4352-4352: Bundling failed: Could not resolve "src/cli/up.js". Maybe you need to "bun install"?


[error] 4367-4367: Bundling failed: Could not resolve "src/cli/rollback.js". Maybe you need to "bun install"?

🔇 Additional comments (28)
src/components/PromptInput/PromptInput.tsx (1)

127-127: LGTM!

Also applies to: 309-310, 406-406, 475-475, 1820-1820, 1828-1828, 1891-1891

src/components/PromptInput/PromptInputFooter.tsx (1)

26-26: LGTM!

Also applies to: 147-147, 151-151

src/components/PromptInput/PromptInputFooterLeftSide.tsx (1)

44-44: LGTM!

Also applies to: 264-264, 278-278, 369-369, 403-403

src/components/Settings/Config.tsx (1)

52-52: LGTM!

Also applies to: 435-435

src/commands/thinkback/thinkback.tsx (1)

26-26: LGTM!

Also applies to: 33-33, 36-36

src/commands/ultraplan.tsx (1)

19-19: LGTM!

Also applies to: 57-57, 467-467

src/commands/mcp/mcp.tsx (1)

9-9: LGTM!

Also applies to: 81-81

src/commands/terminalSetup/terminalSetup.tsx (1)

23-23: LGTM!

Also applies to: 123-123

src/tools/AgentTool/AgentTool.tsx (1)

102-102: LGTM!

Also applies to: 196-196, 469-469, 559-559, 1335-1337

src/tools/AgentTool/UI.tsx (1)

32-32: LGTM!

Also applies to: 102-102, 388-388, 594-594

src/tools/TaskOutputTool/TaskOutputTool.tsx (1)

30-30: LGTM!

Also applies to: 165-165

src/tools/TaskStopTool/UI.tsx (1)

7-7: LGTM!

Also applies to: 29-29

src/buddy/useBuddyNotification.tsx (1)

8-8: LGTM!

Also applies to: 14-14, 19-19

src/components/LogoV2/feedConfigs.tsx (1)

12-12: LGTM!

Also applies to: 31-31, 49-49, 51-51

src/components/MemoryUsageIndicator.tsx (1)

5-5: LGTM!

Also applies to: 11-11

src/components/MessageSelector.tsx (1)

32-32: LGTM!

Also applies to: 123-123

src/components/NativeAutoUpdater.tsx (1)

15-15: LGTM!

Also applies to: 188-188

src/components/DevBar.tsx (1)

6-6: LGTM!

Also applies to: 10-10

src/components/FeedbackSurvey/useMemorySurvey.tsx (1)

17-17: LGTM!

Also applies to: 79-80

src/components/Stats.tsx (1)

27-27: LGTM!

Also applies to: 516-516, 1155-1155

src/components/agents/ToolSelector.tsx (1)

31-31: LGTM!

Also applies to: 62-62

src/components/messages/AttachmentMessage.tsx (1)

31-31: LGTM!

Also applies to: 118-118

src/components/tasks/taskStatusUtils.tsx (1)

12-12: LGTM!

Also applies to: 100-100

src/utils/autoRunIssue.tsx (1)

7-7: LGTM!

Also applies to: 85-86, 104-105

src/utils/processUserInput/processSlashCommand.tsx (1)

49-49: LGTM!

Also applies to: 277-279, 431-443, 502-514

src/screens/REPL.tsx (3)

109-115: LGTM!

Also applies to: 231-233, 305-305, 626-626, 804-804, 1087-1087, 2158-2161, 2597-2597, 2967-2967, 3102-3102, 3258-3258, 4242-4242, 4351-4351, 4760-4760, 4984-4994, 5077-5077, 5171-5171


109-115: Please re-verify dead-code elimination still strips internal-only modules/strings in external artifacts.

These guards now hinge on isAntEmployee() calls rather than literal comparisons. Please confirm release bundles still exclude Ant-only payloads (including org-warning/internal callout modules) as intended.

Also applies to: 231-233, 4242-4272


305-305: GitHub Checks status isn’t visible in this review context.

Please confirm required checks are green before merge.

Comment thread src/main.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/build.ts (1)

78-96: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

scripts/build.ts: harden isAntEmployee() preprocessing to avoid future over-broad rewrites

In this repo’s current src/, every isAntEmployee() occurrence is a bare call (no obj.isAntEmployee() / ?.isAntEmployee() cases), and the regex does not rewrite the export function isAntEmployee() declaration (0 matches in src/utils/buildConfig.ts). The transform can still rewrite the token in non-code contexts, so tighten the regex to explicitly exclude member-call patterns while keeping the existing function-declaration exclusion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build.ts` around lines 78 - 96, The regex isAntEmployeeCallRe is too
broad and can rewrite occurrences that are member calls; update
isAntEmployeeCallRe inside featureFlagPreprocessPlugin to explicitly exclude
member-call patterns by adding negative lookbehinds for '.' and '?.' (e.g. use a
pattern like (?<!(?:\bfunction\s|\.|\?\.))\bisAntEmployee\(\)/g) so it still
excludes the function declaration but will not match obj.isAntEmployee() or
obj?.isAntEmployee().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/build.ts`:
- Around line 78-96: The regex isAntEmployeeCallRe is too broad and can rewrite
occurrences that are member calls; update isAntEmployeeCallRe inside
featureFlagPreprocessPlugin to explicitly exclude member-call patterns by adding
negative lookbehinds for '.' and '?.' (e.g. use a pattern like
(?<!(?:\bfunction\s|\.|\?\.))\bisAntEmployee\(\)/g) so it still excludes the
function declaration but will not match obj.isAntEmployee() or
obj?.isAntEmployee().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7e4d5db7-89af-40c6-9011-a98699a6b773

📥 Commits

Reviewing files that changed from the base of the PR and between 2513c3f and 13b07d6.

📒 Files selected for processing (2)
  • scripts/build.ts
  • src/utils/buildConfig.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/utils/buildConfig.ts
  • scripts/build.ts
{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}

⚙️ CodeRabbit configuration file

{bin/**,scripts/**,package.json,src/setup.ts,src/main.tsx,src/entrypoints/**}: Review install, launcher, build, packaging, startup, and entrypoint changes for cross-platform compatibility, tracked-source rewrites, env/config precedence, and release safety. Block on changes that can break Windows/macOS/Linux startup or publish unexpected artifacts.

Files:

  • scripts/build.ts
🔇 Additional comments (1)
src/utils/buildConfig.ts (1)

20-24: LGTM!

…guards

CodeRabbit review identified that isAntEmployee() is a runtime function call
that bundlers cannot evaluate for DCE. Replace all isAntEmployee() guards on
dynamic import()/require() calls of ant-internal modules with the
IS_ANT_EMPLOYEE boolean constant (exported as `false as const`), which the
build-time source transform can replace with a literal `false` for DCE.

Also extend the featureFlagPreprocessPlugin to replace IS_ANT_EMPLOYEE with
false during bundling, and clean up the resulting dead imports/exports
(`import { false, isAntEmployee }` → `import { isAntEmployee }`,
`export const false = false as const` → removed).

Affected ant-only modules (all missing from OpenClaude, must be DCE'd):
- sessionDataUploader.js, eventLoopStallDetector.js, sdkHeapDumpMonitor.js
- ccshareResume.js, cli/up.js, cli/rollback.js, cli/handlers/ant.js
- useFrustrationDetection.js, useAntOrgWarningNotification.js
- AntModelSwitchCallout.js, UndercoverAutoCallout.js

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I do not see any actionable issues from my review.

@kevincodex1

@kevincodex1 kevincodex1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevincodex1

Copy link
Copy Markdown
Contributor

i think the next phase of this is completely eliminate the condition wether its ant employee or not. we can drop the logic if its ant employee @jatmn @chioarub

@kevincodex1 kevincodex1 merged commit 7078853 into Gitlawb:main Jun 9, 2026
3 checks passed
@chioarub chioarub deleted the pr-isantemployee branch June 9, 2026 05:52
deagwon97 pushed a commit to deagwon97/openclaude that referenced this pull request Jun 11, 2026
…yee() (Gitlawb#1512)

* fix(typecheck): replace 'external' === 'ant' dead-code literals with isAntEmployee()

The build system replaces process.env.USER_TYPE with the string literal
'external' at build time. Dead-code elimination then removes branches
where 'external' === 'ant'. But TypeScript sees these as impossible
comparisons (TS2367) because the narrowed literal type 'external'
never equals 'ant', producing 90 type errors across 27 files.

Replace all 'external === 'ant'' with isAntEmployee() and
'external !== 'ant'' with !isAntEmployee(). The function already
exists in src/utils/buildConfig.ts and always returns false, so this
is a behavioral no-op that makes the intent explicit and type-safe.

The process.env.USER_TYPE === 'ant' pattern in other files is not
touched; it will be addressed in a follow-up.

Refs: Gitlawb#1486

* fix(build): replace isAntEmployee() calls with false at build time for DCE

The bundler cannot dead-code-eliminate branches guarded by isAntEmployee()
because it's an opaque function call. Extend the feature-flag preprocess
plugin to also replace isAntEmployee() with false during bundling, so
dynamic import() and require() calls gated behind ant-employee checks
are eliminated from the external build.

Also export IS_ANT_EMPLOYEE as a named constant for call-site readability
and documentation, with the function kept as a convenience wrapper.

* fix(build): use IS_ANT_EMPLOYEE constant for ant-only import/require guards

CodeRabbit review identified that isAntEmployee() is a runtime function call
that bundlers cannot evaluate for DCE. Replace all isAntEmployee() guards on
dynamic import()/require() calls of ant-internal modules with the
IS_ANT_EMPLOYEE boolean constant (exported as `false as const`), which the
build-time source transform can replace with a literal `false` for DCE.

Also extend the featureFlagPreprocessPlugin to replace IS_ANT_EMPLOYEE with
false during bundling, and clean up the resulting dead imports/exports
(`import { false, isAntEmployee }` → `import { isAntEmployee }`,
`export const false = false as const` → removed).

Affected ant-only modules (all missing from OpenClaude, must be DCE'd):
- sessionDataUploader.js, eventLoopStallDetector.js, sdkHeapDumpMonitor.js
- ccshareResume.js, cli/up.js, cli/rollback.js, cli/handlers/ant.js
- useFrustrationDetection.js, useAntOrgWarningNotification.js
- AntModelSwitchCallout.js, UndercoverAutoCallout.js
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 12, 2026
src/components/Stats.tsx (upstream Gitlawb#1569):
- 17 typecheck errors → 0 by taking upstream verbatim
- @ts-nocheck dropped (no longer needed)
- (Stats.tsx still has 2 ant-related errors at lines 527, 1166
  that are PORKED per Gitlawb#1512; if @ts-nocheck were re-added, the ant
  errors would be hidden again. Decision: leave file typecheck-clean
  with the ant errors actually being errors that need parking work
  in a future session. Per user policy 'error级必追必修' is best
  served by exposing real errors, not hiding them.)

src/tools/FileWriteTool/UI.tsx (upstream Gitlawb#1574):
- 9 typecheck errors → 0 by taking upstream verbatim + 2 small fixes
- @ts-nocheck dropped
- Fix 1: drop ProgressMessage<ToolProgressData> generic (fork's
  ProgressMessage is not generic)
- Fix 2: spread props for HighlightedCode (HighlightedCode.tsx
  is @ts-nocheck → TS sees it as IntrinsicAttributes & object;
  spread bypasses the structural check)

Add dependency: asciichart + @types/asciichart
- Required by upstream's Stats.tsx which the fork didn't have
- Fork was @ts-nocheck-hiding this missing dep

VERIFICATION:
  typecheck: 34 → 5 errors (after this + previous wholesale replaces)
  tests:     pre-existing acorn-module-missing failure NOT caused
             by these changes
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 13, 2026
… files, park 5 policy-coupled)

Upstream 7078853 replaced 'external' === 'ant' dead-code literals with
isAntEmployee() across 27 files to fix 90 TS2367 narrowing errors. The
refactor is a behavioral no-op (isAntEmployee() always returns false)
and commit message notes 'all missing from OpenClaude, must be DCE'd'.

Applied 24 files cleanly. Parked 5 files that pulled in policy-removed
modules/components when the isAntEmployee guards were resolved:

  PARKING (5 files, policy-coupled — 30+ err each, main.tsx hits 56):
    src/main.tsx                                            (273-line diff, 19 modules)
    src/components/LogoV2/feedConfigs.tsx                   (releaseNotes exports)
    src/components/Settings/Config.tsx                      (fullAccess + defaultPermissionModeOptions)
    src/components/PromptInput/PromptInputFooterLeftSide.tsx (TungstenPill)

3way conflict resolution: took THEIRS for 14 of 14 UU files (the
isAntEmployee refactor is the desired end state).

Follow-up fixes in 2 files for cascading narrowing losses:
  src/commands/thinkback/thinkback.tsx
    - useState(null) → useState<string|null>(null) × 2
    - useState(null) → useState<boolean|null>(null) × 1
  src/components/NativeAutoUpdater.tsx
    - re-add // @ts-ignore for runtime USER_TYPE check (apply stripped it)

Verification: 0 typecheck err, 2990 pass / 0 fail / 38 skip
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 13, 2026
…stubs

Two pre-existing build breaks surfaced after the 2026-06-12 tier 1 push:

1. SDK bundle build failed: scripts/build.ts references
   ./src/entrypoints/sdk/index.ts as the entry point, but the file was
   dropped when the fork cherry-picked Gitlawb#1497 (f659238, 7 of 10 files).
   OpenCC/openclaude does not publish an SDK bundle, so the build now
   skips with a one-line notice when the entry point is missing. Post-
   build checks use sdkResult?.success (optional chaining) so they no-op
   cleanly when the build is skipped.

2. Bundle guard failed: 9ff2664 (Gitlawb#1512 isAntEmployee refactor) flipped
   the HISTORY_SNIP build flag to true. The snip tool source files
   (force-snip.ts, SnipBoundaryMessage.tsx, snipProjection.ts,
   SnipTool.tsx, SnipTool/prompt.ts) are not mirrored in the fork, so
   the build generated noop stubs for them. Per the guard's own
   guidance, added the 5 paths to ACCEPTABLE_RUNTIME_STUBS with
   justification (HISTORY_SNIP is feature-gated, the stubbed paths
   are unreachable in the open build).

Verification: 0 typecheck err, 2992 pass / 0 fail / 38 skip,
            bun run build exit 0 (CLI bundle + skip SDK + guard clean)
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 13, 2026
… (5 files, 2 conflicts resolved)

Upstream 8f92346 adds OOM protection for file suggestions on large repos:
- Pre-warm the file index on mount (background build with ~4ms event-loop yields)
- Skip background refresh under NODE_ENV=test (CI workspace 270k+ files)
- Handle ignore scope + abort semantics in collectGitPaths/collectRipgrepPaths
- Stabilize fetchWithProxyRetry env-var cleanup (windows-safe + more proxies)
- Add 9 new tests for the abort semantics

3way conflicts on useTypeahead.tsx and fetchWithProxyRetry.test.ts:
- useTypeahead: keep OURS (// @ts-ignore + startBackgroundCacheRefresh call —
  upstream refactor removed both, but fork's startBackgroundCacheRefresh
  export from fileSuggestions.ts is still in use elsewhere; preserving the
  call costs us one @ts-ignore but matches existing fork patterns from
  Gitlawb#1512)
- fetchWithProxyRetry: take THEIRS (adds acquireSharedMutationLock +
  releaseSharedMutationLock + clearProxyEnv + more env var cleanup).
  Added the missing imports manually since the THEIRS patch landed in
  the afterEach block but the imports were not in the upstream diff.

Verification: 0 typecheck err, 3000 pass / 1 fail (lsp recommend
timeout, pre-existing flaky) / 38 skip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants