Skip to content

refactor(orchestrate): extract 4 helpers from 345-line postInstall#3343

Open
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-postinstall-helpers
Open

refactor(orchestrate): extract 4 helpers from 345-line postInstall#3343
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-postinstall-helpers

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Apr 23, 2026

Why: postInstall() in orchestrate.ts is 345 lines handling 7+ distinct responsibilities — the longest function in the codebase. Navigating or testing any single subsystem requires reading through the entire monolith.

Changes

Extract 4 focused helpers from postInstall():

  1. installSkillEnvVars(runner) — skill env var base64 encoding + injection into .spawnrc
  2. setupDashboardTunnel(cloud, tunnelCfg, spawnId) — SSH tunnel start, signed preview URL, local browser open, metadata save
  3. setupTelegramPairing(runner) — Telegram pairing code prompt + openclaw pairing call
  4. runInteractiveSession(cloud, launchCmd, spawnId, tunnelHandle) — terminal reset, reconnect loop, exit code handling, child history pull

Reduces postInstall from 345 to ~200 lines. Pure refactor — no behavior change.

Test plan

-- refactor/complexity-hunter

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 23, 2026

CI status: Mock Tests job shows 4 failures, but none are introduced by this PR:

Local bun test in this branch: 2106 pass, 2 fail (same 2 pre-existing failures as main).

Once #3341 merges and this branch rebases, all 4 CI failures should resolve. Draft status is appropriate until then.

-- refactor/pr-maintainer

@la14-1 la14-1 marked this pull request as ready for review April 24, 2026 16:20
@la14-1 la14-1 force-pushed the refactor/extract-postinstall-helpers branch from b049ba5 to 08da7a6 Compare April 25, 2026 08:21
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 25, 2026

Rebased onto main to resolve merge conflicts (package.json version bump).

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 25, 2026

Fixed CI: removed duplicate "version" key in packages/cli/package.json that was introduced during the rebase. bun install was failing with Duplicate key "version" in object literal. CI should pass now.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 26, 2026

This PR has been open for 3+ days with all CI checks passing (ShellCheck, Mock Tests, Biome Lint, Unit Tests, macOS Compatibility — all SUCCESS). It is mergeable with no conflicts.

Requesting human review when convenient.

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-postinstall-helpers branch from 5ae84c4 to b36907f Compare April 29, 2026 06:48
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 29, 2026

Rebased onto main (dropped the now-redundant duplicate-version-key fix commit). Branch is clean with 1 commit. Awaiting human review.

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-postinstall-helpers branch from b36907f to 0fb63e9 Compare April 30, 2026 05:08
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

This PR is ready for review. All CI checks pass and there are no merge conflicts.

-- refactor/pr-maintainer

Extract installSkillEnvVars, setupDashboardTunnel, setupTelegramPairing,
and runInteractiveSession from the monolithic postInstall function.
Reduces postInstall from 345 to ~200 lines with no behavior change.

Agent: complexity-hunter
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@la14-1 la14-1 force-pushed the refactor/extract-postinstall-helpers branch from 0fb63e9 to 3475c22 Compare May 3, 2026 14:19
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

Rebased onto main (was 4 commits behind). Clean rebase, no conflicts.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 4, 2026

Verified in worktree: tests pass (2236/2238, same 2 pre-existing failures as main), lint clean (biome 0 errors). PR is mergeable and ready for review.

-- refactor/pr-maintainer

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.

2 participants