Add worktree switching support#129
Open
goransle wants to merge 11 commits into
Open
Conversation
- Add lib/worktree.js for git worktree discovery - Add dynamic getters (getHighchartsDir/getSamplesDir/getApiDir) to lib/arguments.js - Add /api/worktree endpoints (routes/worktree.js) - Refactor all static highchartsDir/samplesDir imports to use dynamic getters - Add worktree dropdown to nav bar with 🌲 label - Reinitialize file watchers on worktree switch - Add path containment security check
Guard readdirSync in websocket walk() with try-catch to handle ENOENT when a worktree is deleted while the server is running.
There was a problem hiding this comment.
Pull request overview
Adds git worktree awareness to highcharts-utils so the running app can switch between multiple Highcharts checkouts without a server restart, including a UI selector, API endpoints, and dynamic path resolution across routes/watchers.
Changes:
- Introduces worktree discovery (
lib/worktree.js) plus/api/worktreeendpoints to list/select active worktrees. - Refactors path usage to dynamic getters (
getHighchartsDir/getSamplesDir/getApiDir) so routes/static serving follow the selected worktree. - Updates the UI (nav dropdown) and watcher logic to reinitialize file watching after switching worktrees; adds a Playwright-based script for scanning sample console errors.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| views/samples/contents.hbs | Minor template cleanup (whitespace/blank line). |
| views/partials/nav.hbs | Adds worktree selector UI in the top bar next to version display. |
| server.js | Uses dynamic Highcharts dir getter for logging and package.json resolution. |
| scripts/check-samples-console.mjs | New script to crawl sample pages and report console/page errors via Playwright. |
| routes/worktree.js | New API routes for listing worktrees and persisting selected worktree to config. |
| routes/samples/view.js | Switches sample file operations to use getHighchartsDir() dynamically. |
| routes/samples/share.js | Switches sample asset reads to use getHighchartsDir() dynamically. |
| routes/samples/list-samples.js | Switches sample discovery to use getSamplesDir() dynamically. |
| routes/samples/edit.js | Switches editor file reads to use getSamplesDir() dynamically. |
| routes/samples/data.js | Serves sample data files from getSamplesDir() dynamically. |
| routes/samples/contents.js | Passes dynamic highchartsDir to template. |
| routes/samples/compare-view.js | Passes dynamic highchartsDir to template. |
| routes/bisect/commits.js | Refactors to use dynamic Highcharts dir for git operations. |
| routes/bisect/bisect.js | Updates git spawn working directory to dynamic Highcharts dir. |
| public/stylesheets/style.less | Adds layout/styles for the worktree selector in the top bar. |
| public/javascripts/nav.js | Fetches worktrees and posts selection to reload app on switch. |
| lib/worktree.test.js | Adds unit tests for parsing git worktree list --porcelain -z. |
| lib/worktree.js | Implements git worktree discovery/parsing and validity marking. |
| lib/websocket.js | Refactors watcher initialization to support reinit on worktree switch. |
| lib/functions.js | Replaces static dirs with dynamic getters across sample-related helpers. |
| lib/compile-on-demand.js | Uses dynamic Highcharts dir for resolving package/master paths. |
| lib/arguments.js | Adds dynamic getters and a containment check for selected worktree paths. |
| app.js | Serves worktree-dependent static dirs and registers /api/worktree. |
| app-api.js | Serves API docs from dynamically selected worktree’s build output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- getHighchartsDir() validates path exists, auto-clears stale worktreeDir - Worktree discovery uses default highchartsDir, not potentially-stale active dir - latest-commit.js: try-catch around execSync for sudo/Node v24 compat - server.js: null guard for missing package.json
Contributor
|
Works! Messed with my head a bit that you have to |
MarkusBarstad
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test plan
highchartsrepo