Skip to content

[withdrawn]#644

Closed
wsvn53 wants to merge 1 commit intolarksuite:mainfrom
wsvn53:fix/install-wizard-slow-emulator
Closed

[withdrawn]#644
wsvn53 wants to merge 1 commit intolarksuite:mainfrom
wsvn53:fix/install-wizard-slow-emulator

Conversation

@wsvn53
Copy link
Copy Markdown

@wsvn53 wsvn53 commented Apr 23, 2026

Withdrawn by author.

Two independent bugs made `npx @larksuite/cli install` unreliable on slow
emulators (iSH, QEMU, Wine) and underpowered CI runners:

1. **Hardcoded 120s timeouts**. `npm install -g` and `npx skills add`
   child processes take >120s on slow runtimes (measured 140s on iSH
   ARM64 for `skills add https://open.feishu.cn -y -g` which fetches 30+
   skill manifests). The wizard always SIGTERM'd them mid-flight and
   reported "Failed to install skills", even though the underlying
   install was succeeding. New `LARK_CLI_INSTALL_TIMEOUT_MS` env var
   overrides, defaulting to 600000 (10 min) — safe for both fast and
   slow environments.

2. **`skillsAlreadyInstalled` regex never matches**. `skills ls -g`
   prints ANSI colour codes before each name (`\x1b[36mlark-approval`).
   The existing `/^lark-/m.test(out)` consequently returned false every
   time, so subsequent re-runs always triggered a fresh `skills add`
   (with the 120s timeout that then failed). Added a `stripAnsi` helper
   and apply it before matching; now re-runs correctly short-circuit
   with `step2Skip` ("Already installed. Skipped").

Verified on iSH ARM64 under macOS:

- Scenario A (fresh install, skills not present): `skills add` runs for
  ~140s, succeeds, `step2Done` reached. Step 3 (QR code + app config)
  reached in ~5 min total.
- Scenario B (re-run with skills already in ~/.agents/skills/):
  `skillsAlreadyInstalled` matches → `step2Skip` fires immediately →
  Step 3 reached in ~30s.

Both scenarios exit 0 end-to-end. No regressions on fast Docker Alpine
ARM64 (times are unchanged; the higher timeout ceiling only matters
when the child is genuinely slow).
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

The script now computes a configurable install timeout from an environment variable with a 10-minute default and applies it to child processes running npm install -g and npx skills add. Additionally, ANSI escape codes are stripped from skill detection output before regex matching to ensure accurate skill identification.

Changes

Cohort / File(s) Summary
Install Timeout and Skill Detection
scripts/install-wizard.js
Adds configurable INSTALL_TIMEOUT_MS timeout computation applied to npm and npx processes; fixes skill detection by stripping ANSI escape codes from skills ls -g output before regex matching.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Feature/easy setup #464: Introduces the install-wizard.js script that this PR updates with enhanced timeout and ANSI-stripping functionality.

Suggested labels

size/L

Suggested reviewers

  • liangshuo-1

Poem

🐰 A wizard's timeout now keeps perfect time,
With ANSI codes stripped—detection sublime,
No more colorized tricks in the terminal night,
The install process flows calm and right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main bugs fixed: slow emulator timeout issues and ANSI code handling in skills detection.
Description check ✅ Passed The PR description comprehensively covers all template sections: clear summary of both bugs, detailed changes to the script, extensive test plan with multiple scenarios, and explicit related issues status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
scripts/install-wizard.js (2)

97-101: ANSI regex is narrower than the comment suggests — fine for the current use case.

The CSI pattern \x1b\[[0-9;]*[a-zA-Z] won't match sequences that include intermediate bytes or private-mode markers (e.g. \x1b[?25l, \x1b[1;2H with non-letter terminators are covered, but \x1b[?…, \x1b[>…, \x1b[=… and 8-bit CSI \x9b… are not). For the specific goal — stripping the SGR color codes emitted by skills ls before matching /^lark-/m — this is sufficient, and the header comment already scopes it to "good enough for tool output." No change required; just flagging in case stripAnsi is ever reused for richer output.

Consider the widely-used pattern from the ansi-regex package if broader coverage is ever needed:

♻️ Broader ANSI pattern (optional)
 function stripAnsi(s) {
-  // Covers CSI (colour, cursor, etc.) and OSC (title). Good enough for
-  // tool output — we never need to preserve formatting in regex checks.
-  return String(s).replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "").replace(/\x1b\][^\x07]*\x07/g, "");
+  // Covers CSI (including private-mode `?`, `>`, `=`) and OSC (BEL or ST terminated).
+  const pattern = /[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g;
+  return String(s).replace(pattern, "");
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/install-wizard.js` around lines 97 - 101, The current stripAnsi
function uses a narrow CSI/OSC regex that’s fine for stripping SGR color codes
but doesn’t cover private-mode markers, 8-bit CSI, or other sequences; either
update the comment in stripAnsi to explicitly document this limitation
(mentioning it only targets SGR/tool output) or replace the implementation with
a broader, well-tested pattern by importing the ansi-regex package and using it
inside stripAnsi to ensure full ANSI coverage; reference the stripAnsi function
and its existing regex when making the change.

277-290: Consider also stripping ANSI from stderr / capturing both streams.

runSilentAsync's execFile callback resolves only with stdout. If a future version of skills routes the listing to stderr (or mixes warnings in), skillsAlreadyInstalled will silently return false and trigger a redundant re-install — the very bug this PR fixes. Not a blocker since the current skills CLI writes to stdout, but worth a thought.

Also note: applying the full INSTALL_TIMEOUT_MS (10 min default) to skills ls -g is generous — ls should return in seconds. A shorter timeout here would fail faster on a hung environment without affecting the slow-emulator fix for add.

🔧 Optional: tighter timeout for the list check
   try {
     const out = await runSilentAsync("npx", ["-y", "skills", "ls", "-g"], {
-      timeout: INSTALL_TIMEOUT_MS,
+      timeout: Math.min(INSTALL_TIMEOUT_MS, 60000),
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/install-wizard.js` around lines 277 - 290, skillsAlreadyInstalled
currently only checks stdout from runSilentAsync and uses INSTALL_TIMEOUT_MS;
update it to also capture and inspect stderr (or use a combined output) so
stripAnsi is applied to both streams before testing with /^lark-/m, and reduce
the timeout by using a small constant (e.g. SKILLS_LIST_TIMEOUT_MS ~ 30_000)
instead of INSTALL_TIMEOUT_MS for the skills ls call; adjust either
runSilentAsync to return both stdout and stderr or change skillsAlreadyInstalled
to read stderr and combine with stdout, then stripAnsi(combined) and run the
regex against that.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@scripts/install-wizard.js`:
- Around line 97-101: The current stripAnsi function uses a narrow CSI/OSC regex
that’s fine for stripping SGR color codes but doesn’t cover private-mode
markers, 8-bit CSI, or other sequences; either update the comment in stripAnsi
to explicitly document this limitation (mentioning it only targets SGR/tool
output) or replace the implementation with a broader, well-tested pattern by
importing the ansi-regex package and using it inside stripAnsi to ensure full
ANSI coverage; reference the stripAnsi function and its existing regex when
making the change.
- Around line 277-290: skillsAlreadyInstalled currently only checks stdout from
runSilentAsync and uses INSTALL_TIMEOUT_MS; update it to also capture and
inspect stderr (or use a combined output) so stripAnsi is applied to both
streams before testing with /^lark-/m, and reduce the timeout by using a small
constant (e.g. SKILLS_LIST_TIMEOUT_MS ~ 30_000) instead of INSTALL_TIMEOUT_MS
for the skills ls call; adjust either runSilentAsync to return both stdout and
stderr or change skillsAlreadyInstalled to read stderr and combine with stdout,
then stripAnsi(combined) and run the regex against that.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd9139e9-c254-435b-9807-17cd3aaa0d52

📥 Commits

Reviewing files that changed from the base of the PR and between f52ea47 and 20c92c7.

📒 Files selected for processing (1)
  • scripts/install-wizard.js

@wsvn53
Copy link
Copy Markdown
Author

wsvn53 commented Apr 23, 2026

Closing; not ready to pursue this upstream right now. Will reopen later if needed.

@wsvn53 wsvn53 closed this Apr 23, 2026
@wsvn53 wsvn53 changed the title fix(install-wizard): tolerate slow emulators + ANSI in skills ls [withdrawn] Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.49%. Comparing base (f52ea47) to head (20c92c7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   60.65%   62.49%   +1.84%     
==========================================
  Files         416      416              
  Lines       43969    36299    -7670     
==========================================
- Hits        26669    22686    -3983     
+ Misses      15231    11544    -3687     
  Partials     2069     2069              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@20c92c71dc523d3dee5c05a59bf6e4afb8093a1e

🧩 Skill update

npx skills add wsvn53/cli#fix/install-wizard-slow-emulator -y -g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants