Skip to content

Split local PTY provider responsibilities - #17206

Merged
nwparker merged 44 commits into
mainfrom
ra/max-lines-bottom-19-local-pty-provider
Aug 30, 2026
Merged

nwparker merged 44 commits into
mainfrom
ra/max-lines-bottom-19-local-pty-provider

Conversation

@nwparker

@nwparker nwparker commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1972 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1470 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​502

Summary

  • reduce local-pty-provider.ts from 1,584 lines to a 194-line facade
  • split state, launch planning, environment construction/finalization, shell readiness, session operations, foreground inspection, and termination into 13 focused source modules no larger than 268 lines
  • preserve the exact facade exports, singleton/reset ownership, lifecycle ordering, all 138 non-suppression comments, all 137 non-import literals, and every pre-existing callee count
  • preserve public Promise settlement and live provider-option observation, with regression coverage for cancellation-sensitive PowerShell-probe and async environment-build microtask boundaries
  • remove the resolved max-lines baseline entry without touching SSH or remote-provider files

Validation

  • pnpm tc
  • pnpm tc:node
  • all 15 local-pty-*.test.ts files — 187 passed
  • all 54 tests directly referencing LocalPtyProvider — 684 passed
  • exact source preservation audit — facade exports, 137 literals, 138 comments, pre-existing callee counts, and split-internal cycles
  • independent structural and semantic refactor audits
  • changed-file Oxlint plus focused native and type-aware code-quality audits
  • pnpm run check:code-quality:changed — zero new findings
  • pnpm check:max-lines-ratchet — 67 entries
  • pnpm run check:runtime-electron-ratchet
  • max-lines and runtime-ratchet tests — 21 passed
  • changed-file formatting
  • git diff --check

Stacked on #17198.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR decomposes the local PTY provider into focused modules while preserving its facade and lifecycle behavior.

  • Separates launch planning, environment construction, shell readiness, session activation, foreground inspection, and termination.
  • Centralizes local PTY state and provider option types.
  • Adds regression coverage for cancellation-sensitive asynchronous boundaries and live option observation.
  • Updates structural inventories and removes the obsolete max-lines baseline entry.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/main/providers/local-pty-provider.ts Reduced to a facade that delegates the former monolithic responsibilities while retaining the public provider API.
src/main/providers/local-pty-spawn.ts Coordinates launch planning, cancelable environment preparation, native spawning, and session activation.
src/main/providers/local-pty-provider-state.ts Centralizes PTY identity, lifecycle, listener, cleanup, and load-generation state.
src/main/providers/local-pty-termination.ts Encapsulates graceful and forced shutdown, descendant cleanup, physical-exit tracking, and timer ownership guards.
src/main/providers/local-pty-finalize-environment.ts Preserves platform finalization, history isolation, shell wrapper configuration, and startup-delivery environment ordering.
src/main/providers/local-pty-launch-plan.ts Encapsulates platform-specific shell selection, working-directory validation, WSL intent, and PowerShell fallback planning.
src/main/providers/local-pty-shell-readiness-session.ts Owns readiness scanning and deferred startup-command delivery for an activated local PTY.
src/main/providers/local-pty-foreground-inspection.ts Moves foreground process detection and cached Windows agent revalidation behind focused functions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  F[LocalPtyProvider facade] --> P[Launch plan]
  P --> E[Build and finalize environment]
  E --> S[Spawn with platform fallback]
  S --> A[Activate PTY session]
  A --> R[Shell readiness and startup delivery]
  A --> O[Session operations]
  A --> I[Foreground inspection]
  O --> T[Termination and cleanup]
  I --> ST[Shared PTY state]
  T --> ST
  A --> ST
Loading

Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@nwparker
nwparker force-pushed the ra/max-lines-bottom-19-local-pty-provider branch from 01df2ce to 277fce6 Compare August 29, 2026 14:01
…ax-lines-bottom-10-automation-dispatch-events
…9-local-pty-provider

# Conflicts:
#	src/renderer/src/hooks/automation-dispatch-completion.ts
@nwparker
nwparker changed the base branch from ra/max-lines-bottom-18-runtime-environments-pane to main August 30, 2026 03:18
@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 16 minutes.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57bbdb1a-1ed1-4c32-96c2-415242ca5dd0

📥 Commits

Reviewing files that changed from the base of the PR and between 8d3a420 and 4acc81e.

📒 Files selected for processing (21)
  • config/max-lines-baseline.txt
  • src/main/providers/local-pty-finalize-environment.ts
  • src/main/providers/local-pty-foreground-inspection.ts
  • src/main/providers/local-pty-launch-plan.ts
  • src/main/providers/local-pty-provider-spawn-env.test.ts
  • src/main/providers/local-pty-provider-spawn-session.test.ts
  • src/main/providers/local-pty-provider-state.ts
  • src/main/providers/local-pty-provider-types.ts
  • src/main/providers/local-pty-provider-windows-shell-launch.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/main/providers/local-pty-session-activation.ts
  • src/main/providers/local-pty-session-operations.ts
  • src/main/providers/local-pty-shell-readiness-session.ts
  • src/main/providers/local-pty-spawn-environment.ts
  • src/main/providers/local-pty-spawn-state.ts
  • src/main/providers/local-pty-spawn.ts
  • src/main/providers/local-pty-termination.ts
  • src/main/providers/local-pty-windows-spawn-environment.ts
  • src/main/wsl/__fixtures__/wsl-invocation-allowlist.txt
  • src/main/wsl/wsl-invocation-boundary.test.ts
  • src/shared/pane-agent-identity-inventory.test.ts

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.

@nwparker
nwparker merged commit 5650ec8 into main Aug 30, 2026
14 of 30 checks passed
brennanb2025 pushed a commit that referenced this pull request Aug 30, 2026
… observation onto the split modules

main (#17206) cut local-pty-provider.ts from 1584 to 194 lines, moving
getForegroundProcess into local-pty-foreground-inspection.ts. This branch had
rewritten that same method into an observing form, so neither merge side was
resolvable on its own.

Ported rather than resolved:

- local-pty-foreground-inspection.ts now exports observeLocalPtyForegroundProcess
  returning LocalForegroundObservation. getLocalPtyForegroundProcess stays as the
  collapsing wrapper, so every existing caller keeps the exact legacy value.
- inspectProcess moves onto LocalPtyProvider and consumes the observation, which
  keeps the evidence type in local-pty-process-evidence.ts and out of the
  inspection module's import cycle.

The verdict vocabulary crosses the new module boundary unchanged: foreground
reads answer observed / unverifiable, children answer live / unverifiable /
exited, and a degraded or thrown read stays unverifiable rather than collapsing
into an exit.
brennanb2025 pushed a commit that referenced this pull request Aug 30, 2026
…o the split modules

main (#17206) split local-pty-provider.ts across 17 modules, so this branch's six
tombstone hooks no longer had a file to sit in. Distributed to where the state
they guard now lives:

- ptyObservedExits declared beside ptyPhysicalExits in local-pty-provider-state.ts
- cleared on spawn and recorded on exit in local-pty-session-activation.ts
- recorded on the app-quit path in local-pty-termination.ts
- ptyAbsenceVerdict and the test reset stay on local-pty-provider.ts

The tombstone deliberately does NOT clear in clearPtyState: app quit records the
exit and then clears per-id state, so erasing it there would destroy the very
verdict it just observed.

Absence stays two-valued and asymmetric. Only an id whose exit this provider
watched answers exited; an unknown id, an evicted entry, or a provider that
cannot answer degrades to unverifiable. Loss of contact is never exit evidence.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Split speech session lifecycle

* Split terminal output scheduler pipeline

* Split mobile browser pane modules

* Prune resolved max-lines suppressions

* Split pane tree equalization logic

* Extract mobile troubleshoot screen styles

* Split external automation manager

* Split main window service attachments

* Split hosted review creation checks

* Split automation dispatch event handling

* Split settings navigation metadata

* Split daemon initialization lifecycle

* Split GitLab item dialog

* Split relay dispatcher layers

* Split mobile host screen

* Retarget mobile view settings source test

* Split runtime file client layers

* Split ports panel layers

* Split runtime environments pane layers

* Split local PTY provider responsibilities

* Fix F3-speech for stablyai#17123

* Fix F1-cycle for stablyai#17131

* Fix F4-navtest for stablyai#17157

* Fix F2-allowlist for stablyai#17161
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.

1 participant