Skip to content

refactor(pty): structure Windows PTY startup - #1682

Merged
skevetter merged 2 commits into
mainfrom
refactor/pty-structure-windows-start
Oct 25, 2026
Merged

skevetter merged 2 commits into
mainfrom
refactor/pty-structure-windows-start

Conversation

@skevetter

@skevetter skevetter commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Splits startPty in pkg/pty/start_windows.go into named private steps: resolveCommand, newConsoleAttrList, processEnvBlock, createConsoleProcess, and closeChildPipeEnds.
  • startPty keeps every defer, the error-return order, and both goroutine starts (waitInternal, then killOnContext when a context is set).
  • No public API change; startPty drops from cyclomatic complexity 21 to 11.

Why

startPty mixed command resolution, ConPTY attribute setup, environment construction, process creation, and pipe hand-off in one 116-line function. Each step is now a function with one job, which makes the Windows start path reviewable in isolation. Defers and goroutine starts stay in startPty because defer LIFO order determines handle and kill ordering.

Validation

  • mise run cli:format: no changes.
  • mise run cli:lint:ci: exit 0, 0 issues.
  • go test ./pkg/pty/...: ok for pkg/pty and pkg/pty/ptytest (native, not Windows runtime).
  • GOOS=windows go test -c -o /dev/null ./pkg/pty/: compiles, exit 0.
  • GOOS=windows golangci-lint run ./pkg/pty/...: 22 issues, same count as HEAD before this refactor (all pre-existing, on moved code).
  • GOOS=windows go vet ./pkg/pty/: only the pre-existing unsafe.Pointer finding (line 116). Kept the conversion; it is the documented HPCON-as-lpValue pattern.
  • Not run: StartWindowsSuite (pkg/pty/start_windows_test.go) executes cmd.exe and needs a Windows host. Windows runtime behavior is unverified in this PR.

CodeRabbit CLI

  • Pre-rebase, head 098724c9e, base da973e6b738533fdcf40e2b625b65c2e25d3a43f: coderabbit review --agent --fresh --committed --base-commit da973e6b738533fdcf40e2b625b65c2e25d3a43f completed, 0 findings, reviewed pkg/pty/start_windows.go.
  • Rebased, head 1cb69807537a7038f179e0f488d230ca28757aaf, base df78ff317a1c698388924d553d7ee69b910c528c, attempt 1: coderabbit review --agent --fresh --committed --base-commit df78ff317a1c698388924d553d7ee69b910c528c failed with rate_limit ("Rate limit exceeded", recoverable; 3 of 3 free OSS reviews used, 42 minute wait).
  • Rebased, head 1cb69807537a7038f179e0f488d230ca28757aaf, base df78ff317a1c698388924d553d7ee69b910c528c, attempt 2: same command completed, review_completed, 0 findings, reviewed pkg/pty/start_windows.go.

Auto-merge

Not enabled. Draft; coordinator owns ready/merge.

Next

Run StartWindowsSuite on a Windows runner to confirm runtime behavior.

Summary by CodeRabbit

  • New Features
    • SSH-launched processes now receive the SSH_TTY environment variable.
    • Processes started without a specified working directory now use the current directory.

@skevetter skevetter added the auto-refactor Automated refactor PR label Oct 24, 2026
@netlify

netlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 1cb6980
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6adc4f7e24b67e1c50fa5388

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b68c283b-f826-4fbb-b97d-b00259506752
Commits

Reviewing files that changed from the base of the PR and between df78ff3 and 1cb6980.

Files selected for processing: 1
  • pkg/pty/start_windows.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

The Windows startPty function delegates command resolution, environment construction, console attribute setup, process creation, and child-pipe closure to helper functions.

Changes: Windows PTY startup

Layer / File(s) Summary
Command and environment preparation
pkg/pty/start_windows.go
startPty uses helpers to resolve the command and directory and to build the environment block. SSH requests add SSH_TTY; non-SSH requests preserve a nil environment.
Console process startup and pipe closure
pkg/pty/start_windows.go
Helpers set the console attribute, create the process with extended startup and Unicode environment flags, and close both child pipe ends. Pipe closure returns the output-close error first, if present.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested labels: size/m, surface-refactor

Merge Risk: Minimal · up to 1cb69

No actionable startup regression is established. The change is mergeable after normal checks, though Windows runtime behavior has not been tested.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: restructuring Windows PTY startup.
Description check Passed The description clearly explains what changed, why it changed, and how it was validated. It identifies the refactor, test results, pre-existing findings, and the missing Windows runtime verification. …
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.
Full details: Description check

Explanation

The description clearly explains what changed, why it changed, and how it was validated. It identifies the refactor, test results, pre-existing findings, and the missing Windows runtime verification. It does not use the repository template headings or include explicit AI-assistance, issue-link, or checklist declarations, but the core required information is present.

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@netlify

netlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit 1cb6980
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6adc4f7ebda97f8bdc797f74
😎 Deploy Preview https://deploy-preview-1682--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@skevetter
skevetter force-pushed the refactor/pty-structure-windows-start branch from 098724c to 1cb6980 Compare October 24, 2026 06:26
@skevetter
skevetter marked this pull request as ready for review October 24, 2026 07:15

Copy link
Copy Markdown
Contributor Author

@greptileai review

@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The refactor appears safe to merge; no actionable issues were found.

Summary

Splits Windows PTY startup into five private helpers without changing the public API.

  • Windows PTY startup now separates command setup from process launch.

Reviews (1) · Last reviewed commit: "refactor(pty): trim restating comments i..." · Reviewed by Greptile

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 40 minutes.

Copy link
Copy Markdown
Contributor Author

Coordinator gate update at head 1cb6980: CI is green, both commits are verified, Greptile reviewed this head at 5/5 with no actionable issues, and the local CodeRabbit CLI completed with 0 findings on this head. GitHub CodeRabbit has not completed review coverage; its status remains "Review rate limited" even after the stated 40-minute reset window and one manual full-review request. Leaving this PR ready and unmerged until GitHub CodeRabbit review completes.

@skevetter

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@skevetter
skevetter merged commit 825dd3d into main Oct 25, 2026
115 checks passed
@skevetter
skevetter deleted the refactor/pty-structure-windows-start branch October 25, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-refactor Automated refactor PR size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant