Skip to content

Fix start:test isolated config after split-config refactor - #2958

Merged
katinthehatsite merged 1 commit into
trunkfrom
fix-start-test-isolated-config
Apr 2, 2026
Merged

Fix start:test isolated config after split-config refactor#2958
katinthehatsite merged 1 commit into
trunkfrom
fix-start-test-isolated-config

Conversation

@wojtekn

@wojtekn wojtekn commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude Code was used to investigate the root cause and implement the fix.

Proposed Changes

This PR adds DEV_CONFIG_DIR env var support to getConfigDirectory() in tools/common/lib/well-known-paths.ts, redirecting the entire ~/.studio/ config directory when set.

The config refactor split the single appdata file into three files (app.json, cli.json, shared.json). The old DEV_APP_DATA_PATH only redirected app.jsoncli.json (sites, snapshots) and shared.json (auth) still pointed at ~/.studio/, so real developer sites could appear in the test instance.

Testing Instructions

  1. Run npm run start:test — app should open with no sites and no auth
  2. Confirm /tmp/studio-test/ is created with the isolated config files
  3. Confirm ~/.studio/cli.json and ~/.studio/shared.json are unchanged after the session
  4. Run npm start and confirm your real sites still appear normally

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
DEV_APP_DATA_PATH only redirected app.json, leaving cli.json and shared.json
pointing at ~/.studio/ — real sites could leak into the test instance.

Adds DEV_CONFIG_DIR support to getConfigDirectory() so a single env var
redirects the entire config directory, covering all three split config files.
Removes the now-redundant DEV_APP_DATA_PATH check from getUserDataFilePath().
@wojtekn wojtekn self-assigned this Apr 1, 2026
@wojtekn
wojtekn requested a review from a team April 1, 2026 13:32
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing f1d9df3 vs trunk

app-size

Metric trunk f1d9df3 Diff Change
App Size (Mac) 1271.54 MB 1271.54 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk f1d9df3 Diff Change
load 1884 ms 1543 ms 341 ms 🟢 -18.1%

site-startup

Metric trunk f1d9df3 Diff Change
siteCreation 8174 ms 8216 ms +42 ms ⚪ 0.0%
siteStartup 4840 ms 4932 ms +92 ms 🔴 1.9%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@katinthehatsite katinthehatsite left a comment

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.

These changes look good to me 👍 I was able to see the correct files in the target directory:

Image
@katinthehatsite

Copy link
Copy Markdown
Contributor

I will retrigger the failed tests now 👀

@katinthehatsite
katinthehatsite merged commit f1aced1 into trunk Apr 2, 2026
11 checks passed
@katinthehatsite
katinthehatsite deleted the fix-start-test-isolated-config branch April 2, 2026 08:21
chubes4 added a commit that referenced this pull request Jul 2, 2026
Two linked bugs let a freshly-converted MySQL site break on the next
`studio start`, even though the conversion itself imported cleanly:

1. paths.ts hardcoded the daemon home to ~/.studio, ignoring the
   DEV_CONFIG_DIR sandbox that the rest of the CLI honors via
   getConfigDirectory(). A sandboxed CLI (the MySQL POC, or start:test)
   therefore connected to the default ~/.studio daemon, which for the POC
   is the stock MySQL-unaware Studio.app daemon — it never launched mysqld
   and drove the isolated site through the wrong process manager. Derive
   PROCESS_MANAGER_HOME from getConfigDirectory() so the daemon socket
   lives alongside cli.json/shared.json. When DEV_CONFIG_DIR is unset
   getConfigDirectory() returns ~/.studio, so normal installs are byte-for
   -byte unchanged; an explicit STUDIO_PROCESS_MANAGER_HOME still wins.
   This finishes what #2958 set out to do ("redirect the entire config
   directory") but which only covered well-known-paths.ts.

2. ensureWpConfig() silently fell back to DB_NAME='wordpress' whenever the
   engine config was absent. Combined with (1), a start via the wrong
   daemon rewrote a converted site's wp-config.php back to 'wordpress',
   severing it from its studio_<id> database. Add a guard that refuses to
   overwrite an existing non-default DB_NAME when no MySQL engine config
   is provided, instead of corrupting the config.

Proven on the real studio-native-local-runtime site: full stop -> start
round-trip now boots on MySQL 8.4.10, serves HTTP 200, and keeps
DB_NAME=studio_1322c571c44e43ca80826cd1 with all content intact.

## AI assistance
- **AI assistance:** Yes
- **Tool(s):** Claude Opus 4.8 via Claude Code
- **Used for:** Root-causing the two bugs from source, writing the fixes
  and the guard unit test, and verifying the stop/start round-trip on the
  converted runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants