Skip to content

fix(windows): resolve daemon project root in src mode; add start/stop…#171

Open
edenahoussou wants to merge 1 commit intonexu-io:mainfrom
edenahoussou:fix-windows-daemon-root-startup
Open

fix(windows): resolve daemon project root in src mode; add start/stop…#171
edenahoussou wants to merge 1 commit intonexu-io:mainfrom
edenahoussou:fix-windows-daemon-root-startup

Conversation

@edenahoussou
Copy link
Copy Markdown

Summary
This PR fixes a Windows dev-mode issue where Open Design launched correctly but loaded an empty catalog (no skills / design systems) in the UI, and adds helper scripts to make local startup more reliable.

Problem
On Windows, when running the daemon from source (apps/daemon/src), PROJECT_ROOT was resolved as if runtime always came from dist.
As a result, the daemon scanned the wrong folders for:

skills/
design-systems/
Observed behavior:

UI showed no templates/design systems
daemon API returned empty arrays:
/api/skills -> skills: []
/api/design-systems -> designSystems: []
Root Cause
resolveProjectRoot() only handled dist, not src:

dist path worked
src path resolved one level too high in dev mode
Changes
Daemon root resolution fix
File: apps/daemon/src/server.ts
Updated resolveProjectRoot() to treat both dist and src as daemon subdirs and normalize to the same repo root logic.
Startup ergonomics on Windows
Added start-open-design.ps1
uses Node 24.7.0
starts daemon
detects daemon URL/port
starts web on localhost:3000 with matching OD_PORT
Added stop-open-design.ps1
stops tools-dev services
kills lingering process bound to port 3000
Dependency build approval
package.json updated in pnpm.onlyBuiltDependencies to include sharp
reflects the explicit pnpm approve-builds step needed in this environment
Validation
Validated locally on Windows:

daemon running and reachable
API now returns populated catalogs:
skills_count=31
design_systems_count=72
web UI loads catalog correctly (templates/design systems visible)
CLI detection remains functional
startup scripts work end-to-end
Notes
This is a dev/runtime path resolution fix; no behavior change expected for production builds that run from dist.
The sharp approval entry is environment/security-policy related and keeps install flow deterministic on this setup.
How to test
pnpm install
pnpm tools-dev start daemon

or .\start-open-design.ps1

Then verify:

GET /api/skills returns non-empty skills
GET /api/design-systems returns non-empty designSystems
UI shows skills/design-system pickers populated.

@lefarcen lefarcen added the bug-fix Fixes an existing bug label Apr 30, 2026
@lefarcen lefarcen self-requested a review April 30, 2026 11:56
Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

Hey @edenahoussou, thanks for tackling this Windows dev-mode bug! 🎉 The daemon path fix is solid — treating both dist and src as daemon subdirs is exactly the right approach.

However, the PowerShell scripts introduce several issues that need addressing before merge. See inline comments below.

Comment thread start-open-design.ps1
@@ -0,0 +1,44 @@
$ErrorActionPreference = "Stop"

$repoRoot = "C:\Users\aeden\Documents\Codex\2026-04-29\https-github-com-nexu-io-open"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Hardcoded absolute path breaks portability

This path is specific to your machine (C:\Users\aeden\Documents\Codex\2026-04-29\...). Anyone else who clones the repo will get a runtime error.

Fix: Use a dynamic resolution based on the script's location:

$repoRoot = Split-Path -Parent $PSScriptRoot

Or accept it as a script parameter:

param(
  [string]$RepoRoot = (Split-Path -Parent $PSScriptRoot)
)

Comment thread start-open-design.ps1
& $pnpmCmd tools-dev start daemon | Out-Host

$statusOutput = & $pnpmCmd tools-dev status | Out-String
$daemonUrl = [regex]::Match($statusOutput, 'http://127\.0\.0\.1:(\d+)').Value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Regex extraction has no fallback validation

If the regex fails to match (e.g., tools-dev status output format changes), the script throws. But the error message won't tell the user what the actual output was.

Fix: Show the actual status output in the error:

if (-not $daemonUrl) {
  Write-Error "Unable to detect daemon URL from tools-dev status. Output was:`n$statusOutput"
  exit 1
}

Comment thread start-open-design.ps1

$existing = Get-NetTCPConnection -LocalPort 3000 -State Listen -ErrorAction SilentlyContinue
if ($existing) {
$existing | ForEach-Object {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Force-killing processes on port 3000 without confirmation

This will silently terminate ANY process listening on 3000, even if it's not a previous pnpm dev run (e.g., another dev server, Vite, etc.).

Fix: Add a confirmation prompt or at least log which process is being killed:

$existing | ForEach-Object {
  $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
  Write-Warning "Terminating process $($proc.Name) (PID $($proc.Id)) on port 3000"
  Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue
}

Comment thread stop-open-design.ps1
@@ -0,0 +1,19 @@
$ErrorActionPreference = "SilentlyContinue"

$repoRoot = "C:\Users\aeden\Documents\Codex\2026-04-29\https-github-com-nexu-io-open"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Same hardcoded path issue as start script

See comment on start-open-design.ps1:3. Use $PSScriptRoot or script parameter.

Comment thread package.json
"electron",
"esbuild"
"esbuild",
"sharp"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 Why does sharp need explicit approval here?

The PR description mentions "environment/security-policy related" but doesn't explain which policy or why sharp triggers it.

Suggestion: Add a comment in the PR (or inline in package.json) explaining the context — e.g., "sharp v0.x.x triggers pnpm's native build confirmation due to postinstall compilation; approved after security audit on [date]".

This helps future maintainers understand why it's allowlisted.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e032ac04bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread start-open-design.ps1
Comment on lines +3 to +5
$repoRoot = "C:\Users\aeden\Documents\Codex\2026-04-29\https-github-com-nexu-io-open"
$webDir = Join-Path $repoRoot "apps\web"
$pnpmCmd = "C:\Program Files\nodejs\pnpm.cmd"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive repo/pnpm paths dynamically in startup scripts

These scripts are hard-coded to one developer’s local paths (C:\Users\aeden\... and C:\Program Files\nodejs\pnpm.cmd), so they fail immediately on any other Windows machine before starting or stopping Open Design. Because they were added as general helper scripts, this makes them unusable for most contributors unless they manually edit the files first.

Useful? React with 👍 / 👎.

Comment thread stop-open-design.ps1
Comment on lines +11 to +15
$existing = Get-NetTCPConnection -LocalPort 3000 -State Listen -ErrorAction SilentlyContinue
if ($existing) {
Write-Host "Stopping web process on port 3000..."
$existing | ForEach-Object {
Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid killing unrelated services bound to port 3000

This unconditionally force-kills every process listening on port 3000, which can terminate unrelated local apps (e.g., another dev server) whenever this stop script runs. The bug appears whenever port 3000 is shared by non-Open Design processes, so shutdown should be scoped to the process started by this workflow rather than all listeners.

Useful? React with 👍 / 👎.

@lefarcen
Copy link
Copy Markdown
Contributor

Lens B — Reasoning Completeness

Beyond the code issues above, a few design questions the PR doesn't address:

1. Cross-platform parity
The PR adds Windows-specific scripts but doesn't mention Linux/macOS equivalents.

  • Should there be start-open-design.sh / stop-open-design.sh for consistency?
  • Or is the Windows path the only platform where pnpm tools-dev ergonomics are problematic?
  • If Windows-only, worth documenting why (e.g., "Windows lacks a standard shell with builtin process management primitives" or similar).

2. CI/automation implications
These scripts reference nvm use 24.7.0 and hardcoded paths.

  • Are they intended for CI (e.g., GitHub Actions Windows runners)?
  • Or strictly local dev convenience?
  • If CI: need to handle headless mode (no Write-Host interactivity).
  • If dev-only: should they live in scripts/ or tools/ rather than repo root? (root pollution concern)

3. Alternative approaches
Why PowerShell scripts instead of:

  • package.json scripts ("dev:windows": "...") that work cross-platform via npm-run-all or similar?
  • Extending tools-dev itself to handle platform-specific quirks (e.g., tools-dev start --windows-mode)?
  • Using a tool like concurrently or pm2 for process orchestration?

Not saying those are better — just that the PR doesn't explain the trade-offs. Knowing why PowerShell was chosen (e.g., "need native Windows process control for reliable port cleanup") helps reviewers assess fit.

4. Prod vs dev boundary
The PR says "dev/runtime path resolution fix; no behavior change expected for production builds that run from dist."

But what happens if someone accidentally runs from src/ in production? The fix now allows it, whereas before it would fail early.

  • Is that desirable (more flexible deployment)?
  • Or risky (dev code paths leaking into prod)?
  • Should there be an explicit guard (e.g., if (base === 'src' && process.env.NODE_ENV === 'production') throw new Error(...))?

These aren't blockers for the daemon fix itself (which is correct), but addressing them would make this PR production-ready for the scripting additions. Let me know if you'd like to iterate on the scripts or if you prefer to land the daemon fix separately and defer the Windows ergonomics to a follow-up PR.

@lefarcen
Copy link
Copy Markdown
Contributor

Hi @edenahoussou! 🎉

Thanks for the contribution — fixing the Windows dev-mode catalog empty issue is important for cross-platform dev experience. The daemon path resolution fix is solid.

I've run a deep review (code correctness + design reasoning) and left inline comments on the PowerShell scripts. Once those are addressed, this will be ready to merge.

Looking forward to seeing the updated version!

— open-design team

@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 1, 2026

Hey @edenahoussou! 👋

I took another look at the PR with fresh eyes. The daemon path resolution fix ( handling both dist and src) is solid and addresses the root cause perfectly. 🎯

However, I noticed the PowerShell scripts have a few architecture concerns that would make them fragile for other contributors:

🚨 Hardcoded paths

start-open-design.ps1 and stop-open-design.ps1 contain:

  • $repoRoot = "C:\Users\aeden\Documents\..." (your local absolute path)
  • $pnpmCmd = "C:\Program Files\nodejs\pnpm.cmd" (assumes specific install location)

Impact: These scripts will fail for anyone who doesn't have the exact same folder structure or pnpm install location.

💡 Suggested path forward

Since the daemon fix itself is the critical part and already solves the Windows catalog empty issue, here are two options:

Option A: Make scripts portable (recommended if you'd like to keep them)

Replace hardcoded paths with dynamic resolution:

# Auto-detect repo root from script location
$repoRoot = Split-Path -Parent $PSScriptRoot

# Use pnpm from PATH (or detect via Get-Command)
$pnpmCmd = (Get-Command pnpm -ErrorAction Stop).Source

This way the scripts work for any contributor on any Windows machine.

Option B: Split the PR (faster path to merge)

  1. This PR: Keep only the daemon fix (server.ts + package.json sharp entry) — these are the critical changes
  2. Separate PR/discussion: Move the PowerShell scripts to a follow-up where we can:
    • Design them to fit into the existing tools-dev / platform wrapper system
    • Make them portable and cross-platform
    • Ensure they work in CI/CD contexts

Why this matters

open-design already has pnpm tools-dev as the canonical dev flow. Adding parallel startup mechanisms that don't integrate with tools-dev creates fragmentation and maintenance burden. Ideally, any Windows-specific ergonomics should layer on top of tools-dev, not bypass it.


No rush — take your time to decide which approach works best for you. The daemon fix is great work and we definitely want to land that. Let me know how you'd like to proceed! 🙌

@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 2, 2026

Hi @edenahoussou!

Just checking in — it's been about 38h since your last update, and there are still some review comments to address.

No rush if you're busy. If anything in the feedback was unclear or you'd like a specific suggestion, just reply here. If you've moved on, feel free to close the PR.

Thanks for the contribution!
— open-design team

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

Labels

bug-fix Fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants