Skip to content

Commit f8b6193

Browse files
authored
Merge pull request #99 from levelcodeai/feat/dev-editor-identity
feat(dev): a run from source is its own app — levelcode-dev:// and its own bundle id
2 parents bd4daf5 + 3c6b256 commit f8b6193

7 files changed

Lines changed: 1011 additions & 8 deletions

File tree

‎CLAUDE.md‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extensions/levelcode-hackability/ user init script + Atom/NPP keymap presets + p
4040
extensions/levelcode-sync/ 'levelcode' auth provider that lights up the built-in Settings Sync (LevelCode Sync, S0)
4141
extensions/levelcode-updater/ notify-only update checker (polls the update feed; never auto-applies)
4242
patches/levelcode-core.patch our core source edits, applied on bootstrap
43-
scripts/ bootstrap.sh, apply-branding.mjs, run-dev.sh, build-macos.sh, make-dmg.sh, make-icon.sh; atom (CLI launcher) + install-level.sh
43+
scripts/ bootstrap.sh, apply-branding.mjs, run-dev.sh, editor-identity.mjs, build-macos.sh, make-dmg.sh, make-icon.sh; atom (CLI launcher) + install-level.sh
4444
tools/ dependency-free reference servers: sync-server (/v1 Settings-Sync), update-server (/api/update feed)
4545
vscode/ GITIGNORED upstream Code-OSS checkout (generated)
4646
```
@@ -55,6 +55,33 @@ vscode/ GITIGNORED upstream Code-OSS checkout (generated)
5555
./scripts/make-icon.sh # regenerate .icns from branding/icons/levelcode-source.png (sips+iconutil)
5656
```
5757

58+
## The dev editor is its own app (keep it that way)
59+
60+
To macOS a run from source and the installed LevelCode used to be ONE app — same bundle id, same
61+
`levelcode://` scheme — so a sign-in started in the dev editor was handed back to the app in
62+
/Applications. `run-dev.sh` now gives the dev run its own identity (`scripts/editor-identity.mjs dev`):
63+
64+
- **Identity:** `branding/product.dev.json` — scheme `levelcode-dev`, bundle id `ai.levelcode.app.dev`.
65+
Both must differ from the shipped ones; a scheme alone still lets macOS confuse the two apps.
66+
- **Two halves, both required.** Runtime: `vscode/product.overrides.json` (Code-OSS reads it only when
67+
running from source, never packages it). macOS: the dev Electron bundle's `Info.plist`, then
68+
`lsregister`. The bundle is regenerated when Electron changes, so the step runs on every launch.
69+
- **Both or neither, and confirmed.** The two files are replaced as one change (staged, renamed, undone
70+
if the second rename fails). Then the step asks macOS which app opens `levelcode-dev://` and FAILS —
71+
`run-dev.sh` stops before launching — unless the answer is this bundle. `lsregister` exiting 0 is
72+
not that answer: it registers a bundle it will never route to.
73+
- **`branding/product.overlay.json` is the product that ships — never put a dev value in it.**
74+
`build-macos.sh` runs `editor-identity.mjs check-release` and fails a build that is not
75+
`levelcode://` + `ai.levelcode.app`, or that carries an overrides file.
76+
- **Auth code never spells a scheme.** `accountSignIn()` builds the callback from
77+
`vscode.env.uriScheme`; that is why the dev identity needed no auth change. Keep it so.
78+
- **The server must be told:** `LEVELCODE_EXTRA_EDITOR_SCHEMES=levelcode-dev` on the backend the dev
79+
editor signs in to (thin.ly `Levelcode::EditorCallback`). Off by default, and it only ever accepts
80+
`levelcode-<variant>`. Symptom when missing: the browser lands on the account page and the editor
81+
hears nothing.
82+
- A LaunchServices handler must live outside temp folders — a bundle under `/tmp` is registered but
83+
never chosen. Tests therefore run on fixtures and do not register anything (`test/editorIdentity.test.js`).
84+
5885
## Toolchain (hard requirements — these bit us)
5986

6087
- **Node = `vscode/.nvmrc` (currently 24.15.0)**. Older majors fail to compile native modules.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ LevelCode is a **clean overlay on top of Code-OSS**, not a vendored copy of the
4949
./scripts/make-dmg.sh # wrap it into a distributable .dmg
5050
```
5151

52+
**A run from source is its own app.** `run-dev.sh` gives the dev editor its own macOS identity — bundle id `ai.levelcode.app.dev` and the `levelcode-dev://` scheme (`branding/product.dev.json`) — so it can sit beside an installed LevelCode without the two answering each other's links. Signing in from it needs a server that accepts that scheme: set `LEVELCODE_EXTRA_EDITOR_SCHEMES=levelcode-dev` on the backend it signs in to. No server accepts it otherwise, and a sign-in that ends on the account page in the browser, with the editor hearing nothing, is the sign that it is not set.
53+
5254
See [`CLAUDE.md`](./CLAUDE.md) for the full repo map + build details and [`PLAN.md`](./PLAN.md) for the roadmap.
5355

5456
## Status

‎branding/product.dev.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"_comment": "The identity of LevelCode RUN FROM SOURCE (scripts/run-dev.sh) — never of a build. To macOS the dev editor and the installed app were one app: same bundle id, same levelcode:// scheme, so a sign-in started in the dev editor was handed back to the app in /Applications. scripts/editor-identity.mjs gives the dev run these two values instead: at runtime through vscode/product.overrides.json (read only when running from source), and on the dev Electron bundle's Info.plist. branding/product.overlay.json — the product that ships — is not touched by any of it. The scheme must be levelcode-<variant>: that is the only shape a server can be told to accept (LEVELCODE_EXTRA_EDITOR_SCHEMES, thin.ly).",
3+
4+
"urlProtocol": "levelcode-dev",
5+
"darwinBundleIdentifier": "ai.levelcode.app.dev"
6+
}

0 commit comments

Comments
 (0)