Files
openclaude/scripts/externals.ts
T
ArkhAngelLifeJiggyandGitHub 3bf6ccd6d8 fix: preserve raw mode across component re-renders (issue #843) (#1198)
* fix: preserve raw mode across component re-renders (issue #843)

* fix(input): only reset raw mode on explicit isActive=false, not on MCP re-render churn (issue #843)

* fix: balance raw mode for isActive false transitions + add regression test

Fixes the issue where cleanup closes over stale isActive=true and returns
early without calling setRawMode(false), leaving rawModeEnabledCount
incremented after UI no longer has active useInput.

Changes:
- Use a ref to track whether raw mode was actually enabled
- Check the ref in cleanup instead of stale isActive closure value
- Add 6 regression tests covering the true->false/unmount paths

Addresses jatmn's review feedback: 'fix raw mode balance for isActive: false transitions'

* fix(input): debounce raw-mode reset to survive MCP re-render churn (issue #843)

* fix: add react-test-renderer dep and fix use-input test for CI

- Add react-test-renderer devDependency (required by @testing-library/react-hooks)
- Add @testing-library/react-hooks to INTENTIONALLY_BUNDLED in externals.ts
- Fix use-input.test.ts 'MCP re-render churn' test to use isActive rerender
  instead of separate renderHook calls (refs don't persist across instances)

* fix: address P1 raw-mode counter imbalance and P2 test-dep scope (PR #1196)

P1 (use-input.ts:64-68): skip setRawMode(true) on isActive false->true
when a deferred reset is pending, preventing counter over-increment
that leaked raw mode on final unmount. Test updated to assert
balanced 1-then-1 call pattern (no redundant setRawMode(true)).

P2 (package.json, externals.ts): move @testing-library/react-hooks
from dependencies to devDependencies; remove from INTENTIONALLY_BUNDLED.
2026-06-03 19:54:00 +08:00

133 lines
3.6 KiB
TypeScript

/**
* Shared external dependency lists for CLI and SDK bundles.
*
* Used by build.ts and validate-externals.ts.
* When adding a new dependency to package.json, check if it should be
* added here (large packages, native modules, or packages with many exports).
*/
// Packages that should be kept external in ALL bundles (CLI + SDK)
export const COMMON_EXTERNALS: string[] = [
// Native image processing
'sharp',
// Cloud provider SDKs
'@aws-sdk/client-bedrock',
'@aws-sdk/client-bedrock-runtime',
'@aws-sdk/client-sts',
'@aws-sdk/credential-providers',
'@azure/identity',
'google-auth-library',
// @vscode/ripgrep ships a platform-specific binary alongside its
// index.js and resolves the path via __dirname at runtime. Bundling
// would freeze the build host's absolute path into dist/cli.mjs, so we
// keep it external and rely on the npm package being installed.
'@vscode/ripgrep',
// Orama search engine
'@orama/orama',
'@orama/plugin-data-persistence',
]
// Additional packages external only in the SDK bundle (TUI + heavy deps)
export const SDK_ONLY_EXTERNALS: string[] = [
'react',
'react-reconciler',
'@anthropic-ai/sdk',
'@modelcontextprotocol/sdk',
]
// Packages kept external but NOT listed in package.json dependencies.
// These are dynamically imported at runtime — they're optional and resolved
// from transitive deps or installed by users who need that provider/protocol.
export const OPTIONAL_RUNTIME_EXTERNALS: string[] = [
// Cloud provider SDKs (dynamically imported per-provider)
'@aws-sdk/client-bedrock',
'@aws-sdk/client-bedrock-runtime',
'@aws-sdk/client-sts',
'@aws-sdk/credential-providers',
'@azure/identity',
]
// Computed full lists
export const CLI_EXTERNALS: string[] = COMMON_EXTERNALS
export const SDK_EXTERNALS: string[] = [...COMMON_EXTERNALS, ...SDK_ONLY_EXTERNALS]
// Packages intentionally bundled (not external, not flagged by validation)
// These are small utilities that are fine to inline into the output bundle.
export const INTENTIONALLY_BUNDLED: string[] = [
// Test utilities (bundled, not external)
// Anthropic provider variants (bundled, not the main SDK)
'@anthropic-ai/bedrock-sdk',
'@anthropic-ai/foundry-sdk',
'@anthropic-ai/sandbox-runtime',
'@anthropic-ai/vertex-sdk',
// CLI / TUI utilities
'@alcalzone/ansi-tokenize',
'@commander-js/extra-typings',
'bidi-js',
'chalk',
'cli-boxes',
'cli-highlight',
'commander',
'emoji-regex',
'env-paths',
'figures',
'get-east-asian-width',
'indent-string',
'supports-hyperlinks',
'wrap-ansi',
// Data formats
'jsonc-parser',
'yaml',
'marked',
'turndown',
'xss',
// Data utilities
'ajv',
'auto-bind',
'diff',
'fflate',
'fuse.js',
'ignore',
'lodash-es',
'lru-cache',
'p-map',
'picomatch',
'proper-lockfile',
'qrcode',
'semver',
'shell-quote',
'signal-exit',
'stack-utils',
'code-excerpt',
'type-fest',
// Networking
'axios',
'cross-spawn',
'duck-duck-scrape',
'execa',
'https-proxy-agent',
'tree-kill',
'undici',
'ws',
// React ecosystem (react/react-reconciler are SDK_ONLY_EXTERNALS, bundled in CLI)
'react',
'react-compiler-runtime',
'react-reconciler',
'usehooks-ts',
// Anthropic SDK (external in SDK bundle, bundled in CLI)
'@anthropic-ai/sdk',
// MCP SDK (external in SDK bundle, bundled in CLI)
'@modelcontextprotocol/sdk',
// Schema validation
'zod',
// gRPC (bundled into CLI, not external)
'@grpc/grpc-js',
'@grpc/proto-loader',
// Web scraping
'@mendable/firecrawl-js',
// Language server protocol
'vscode-languageserver-protocol',
// File watching
'chokidar',
]