Skip to content

feat: add platform-specific process attributes support#411

Merged
mostlygeek merged 1 commit intomostlygeek:mainfrom
nikeshparajuli:feat/process-attributes
Nov 25, 2025
Merged

feat: add platform-specific process attributes support#411
mostlygeek merged 1 commit intomostlygeek:mainfrom
nikeshparajuli:feat/process-attributes

Conversation

@nikeshparajuli
Copy link
Copy Markdown
Contributor

@nikeshparajuli nikeshparajuli commented Nov 25, 2025

Add platform-specific process attributes support

Problem

When llama-swap spawns child processes on Windows (such as llama-server instances), console windows appear and remain visible throughout the process lifetime, resulting in a poor user experience. On Windows, .exe processes display console windows by default unless explicitly hidden.

Solution

This PR adds platform-specific process attributes using Go build tags:

  • process_windows.go: Sets HideWindow: true and CREATE_NO_WINDOW flag to hide console windows on Windows
  • process_unix.go: No-op implementation for Unix systems (no changes needed)
  • process.go: Calls setProcAttributes() when spawning processes

Changes

  • Add setProcAttributes() function with platform-specific implementations
  • Apply process attributes to both main command and stop command execution
  • No configuration changes required - works automatically per platform

Testing

Tested on Windows 11. Console windows are now completely hidden during model operations.

Thank you for maintaining this project!

Summary by CodeRabbit

  • Improvements
    • Added platform-specific process attribute configuration to optimize startup and shutdown operations across all systems. Windows systems now receive enhanced process initialization handling, while Unix systems benefit from streamlined attribute configuration. This ensures consistent and appropriate system-level configurations are properly applied during both command startup procedures and graceful termination sequences across all supported environments.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 25, 2025

Walkthrough

This change introduces platform-specific process attribute configuration for upstream commands in the proxy. Calls to setProcAttributes() are wired into the command startup and stop paths, with Unix (no-op) and Windows (hide window) implementations provided via build-tag-specific files.

Changes

Cohort / File(s) Summary
Process setup calls
proxy/process.go
Adds setProcAttributes(p.cmd) call in start() after command configuration and setProcAttributes(stopCmd) call in cmdStopUpstreamProcess() after constructing the stop command.
Unix implementation
proxy/process_unix.go
Defines setProcAttributes(cmd *exec.Cmd) as a no-op function for Unix-like systems (build tag: non-Windows).
Windows implementation
proxy/process_windows.go
Defines setProcAttributes(cmd *exec.Cmd) to set SysProcAttr with HideWindow: true and CreationFlags: 0x08000000 (CREATE_NO_WINDOW) for Windows systems (build tag: windows).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that setProcAttributes() calls are placed in the correct execution paths (startup and stop).
  • Confirm the Windows CreationFlags value (0x08000000) correctly corresponds to CREATE_NO_WINDOW.
  • Validate that the Unix implementation appropriately uses a no-op for the intended behavior.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding platform-specific process attributes support across Unix and Windows systems.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
proxy/process_windows.go (1)

14-14: Consider using a named constant for improved readability.

The magic number 0x08000000 represents CREATE_NO_WINDOW. While correct, a named constant would improve code clarity and maintainability.

Apply this diff to use a named constant:

+const (
+	CREATE_NO_WINDOW = 0x08000000
+)
+
 // setProcAttributes sets platform-specific process attributes
 func setProcAttributes(cmd *exec.Cmd) {
 	cmd.SysProcAttr = &syscall.SysProcAttr{
 		HideWindow:    true,
-		CreationFlags: 0x08000000, // CREATE_NO_WINDOW
+		CreationFlags: CREATE_NO_WINDOW,
 	}
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86e9b93 and fe766f8.

📒 Files selected for processing (3)
  • proxy/process.go (2 hunks)
  • proxy/process_unix.go (1 hunks)
  • proxy/process_windows.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run-tests
🔇 Additional comments (4)
proxy/process_windows.go (1)

1-16: LGTM! Clean platform-specific implementation.

The use of build tags to separate platform-specific code is appropriate, and the combination of HideWindow: true and CREATE_NO_WINDOW flag correctly prevents console windows from appearing when spawning child processes on Windows.

proxy/process_unix.go (1)

1-12: LGTM! Appropriate no-op implementation.

The build tag correctly targets non-Windows platforms, and the no-op implementation is the right approach for Unix systems where console window hiding is not needed.

proxy/process.go (2)

259-259: LGTM! Correct placement of setProcAttributes.

The call is appropriately positioned after command configuration and before execution, ensuring process attributes are applied to the main upstream command.


629-629: LGTM! Consistent application to stop command.

The call ensures that the stop command receives the same process attributes as the main command, maintaining consistent behavior across all spawned processes.

@mostlygeek
Copy link
Copy Markdown
Owner

Hi,

I’ve never seen this happen before; though I don’t run Windows. What version of Windows are you using?

@nikeshparajuli
Copy link
Copy Markdown
Contributor Author

Hi,

I’ve never seen this happen before; though I don’t run Windows. What version of Windows are you using?

Hi, Windows 11. If it matters, we are spawning llama-swap via nodejs.

Here, I ran two models so two separate terminals appeared.

CleanShot 2025-11-24 at 22 26 09

@mostlygeek
Copy link
Copy Markdown
Owner

Interesting. Thanks for the contrib.

@mostlygeek mostlygeek merged commit 06523d8 into mostlygeek:main Nov 25, 2025
3 checks passed
@nikeshparajuli nikeshparajuli deleted the feat/process-attributes branch November 25, 2025 05:40
rohitpaul pushed a commit to rohitpaul/llama-swap that referenced this pull request Mar 29, 2026
Fixes issues on Windows showing new windows for every process llama-swap spawns.
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