Skip to content

fix(dev): separate app identity while sharing sessions and login - #1820

Merged
beruro merged 5 commits into
org2AI:developfrom
Harry19081:dev/dev-instance-shared-login
Sep 15, 2026
Merged

beruro merged 5 commits into
org2AI:developfrom
Harry19081:dev/dev-instance-shared-login

Conversation

@Harry19081

@Harry19081 Harry19081 commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Running development beside the installed app reused org2ai.org2, so the single-instance plugin forwarded the launch to the bundled app and exited without opening a dev window. Giving dev a separate identity must still preserve the user's existing login and session database. First-start “Follow device” styling could also hang after the old theme loader cleared its timeout and waited for animation frames in an occluded WebView, or continue without a working fallback after a CSS failure.

Solution

  • Fix the macOS dev Dock label: before native startup, exec a sibling hard link named ORG2 Dev. This preserves PID, args, environment, cwd, stdio, and resource location; packaged and numbered instances are excluded. Anchor the frontend cleanup title matcher so it does not match the native executable.
  • Use an amber <II> dev icon for startup and native Dock/taskbar updates. The dev identifier overrides the shared Dock-icon preference without writing to it; the installed app retains its chosen icon. Desktop assets are reproducible from the SVG source.
  • Give both dev entry points the ORG2 Dev name and org2ai.org2.dev identifier, separate deep-link schemes, and service ports 13946/17987. Direct binary launches derive the same defaults from the embedded identifier; production build configuration remains unchanged.
  • Share the existing primary login store and ~/.orgii/sessions.db. Keep related session artifacts, settings, projects, and provider history under the same primary data root so both apps can use existing sessions. Numbered test instances remain isolated; explicit environment overrides remain supported.
  • Load the light base stylesheet from HTML and use the shared theme-swap loader, retaining the old style until a replacement loads. CSS failure/timeout retains light styling without changing the “Follow device” preference; a bounded paint wait prevents suspended animation frames from blocking startup.
  • Cover launcher/runtime parity, shared auth and sign-out, real session persistence across separate processes, and theme startup failure cases. Include setup/recovery notes and an architecture/lifecycle review.

These changes support one workflow: launching development alongside the installed app with the same existing sessions and login and usable startup styling.

Potential risks

  • Shared state is intentional: session edits/deletions, settings, and sign-out affect both apps. This changes the dev configuration/default-path policy without changing database schemas or auth-file formats. Earlier .orgii-dev data remains untouched and is not merged. Reverting this patch restores the previous launch configuration without deleting primary data; use an explicit ORGII_HOME for isolated development. Dev and bundled versions must remain schema-compatible.
  • SQLite WAL and the existing 15-second busy timeout handle database-file contention. The writer queue, active-session ownership, frontend notifications, and background workers are process-local. The two-process persistence regression does not establish safe simultaneous execution of the same session or instant cross-app UI refresh. Concurrent token refresh and full background-worker behavior remain unverified.
  • Dark startup loads an additional base CSS file and can temporarily or, after a failed load, persistently display light styling until a later successful theme synchronization. A failure to load the base CSS itself is outside this guard.
  • The macOS dev build directory must support creating a sibling hard link. Failure logs a diagnostic and continues with the original name. One generated alias remains beside the build artifact and is atomically refreshed after rebuilds; a native restart is needed to apply the name. Actual Dock tooltip and full native hot-reload cycles remain visually unverified.
  • The dev icon intentionally stays amber <II> even when the shared Dock-icon preference changes. Native PNG decoding and asset previews were verified; the live Dock/taskbar was not visually inspected.
  • Native cold-start visual confirmation, visible/hidden CPU/RSS measurements, and Windows/Linux runtime testing were not performed. Browser evidence below has no native IPC; its native-menu warning is expected in that harness.

Verification

On the isolated development branch (the latest develop changes were fetched and checked for conflicts):

  • node --test scripts/dev/tauri-dev-processes.test.cjs scripts/tauri/instance-profile.test.cjs scripts/tauri/run-with-features.test.cjs — 19 passed.
  • pnpm test src/config/runtimeInstance.test.ts src/features/Org2Cloud/config.test.ts src/api/http/auth/sharedAuthStorage.test.ts src/features/Org2Cloud/org2CloudAuthAtom.test.ts src/app/root/__tests__/useMobileRelayCloudAuthSync.test.ts src/util/core/init/themeInit.test.ts src/util/ui/theme/__tests__/swapThemeCss.test.ts src/app/root/__tests__/macosWindowStartupSurface.test.ts — 95 passed.
  • cargo test --manifest-path src-tauri/Cargo.toml --test dev_shared_sessions -- --nocapture — 8 passed, including two-process persistence/read-back and numbered-instance isolation.
  • pnpm run typecheck:fast — passed.
  • pnpm exec eslint src/config/runtimeInstance.ts src/config/runtimeInstance.test.ts src/api/http/auth/sharedAuthStorage.ts src/api/http/auth/sharedAuthStorage.test.ts src/util/core/init/themeInit.ts src/util/core/init/themeInit.test.ts src/util/ui/theme/swapThemeCss.ts --max-warnings 0 — passed.
  • pnpm run check:test-placement and git diff --check — passed.
  • node /tmp/orgii-dev-style-qa-pr/guard.cjs — four fresh headless WebKit profiles passed: light, dark, failed dark CSS, and stalled dark CSS; each settled with one stylesheet, working layout, and defined theme tokens. The temporary harness/dependency is not added to the repository.
  • Commit hooks — passed: oxlint, ESLint/Prettier, full TypeScript check, scoped cargo clippy --lib --message-format=short -p database -p org2, and commit-message validation.

During implementation, cargo test --manifest-path src-tauri/Cargo.toml --lib infrastructure::dev_bundled_auth::tests -- --nocapture passed 4 tests (existing linker unwind-size warning). pnpm run tauri:dev --no-cache-guard reached backend readiness beside the installed app, with separate single-instance sockets and backend ports 13946/13847; this native check preceded the shared-data-root follow-up. node --test scripts/dev/startup-watchdog.test.cjs passed 7 and failed 2 unrelated source-shape assertions that still search the pre-refactor Rust crate root for lifecycle handlers.

Full native lifecycle/performance, simultaneous active-session stress, and cross-process token-refresh coverage remain incomplete; no runtime performance improvement is claimed.

Dev icon verification

The final mark is <II>, with smaller brackets (about 25% smaller) around the unchanged II mark. The bracketed mark passed 8 native icon tests; the subsequent bracket-size refinement regenerated assets and was visually inspected. The artwork-only commit hooks passed; no runtime source changed in this revision.

  • node scripts/tauri/dev-icons.mjs — generated desktop PNG/ICNS/ICO assets; inspected 32px, 128px, and 512px previews.
  • cargo test --manifest-path src-tauri/Cargo.toml -p app_window --lib dock_icon::tests -- --nocapture — 8 passed, including macOS native decoding and identity/preference selection.
  • node --test scripts/dev/tauri-dev-processes.test.cjs scripts/tauri/run-with-features.test.cjs — 14 passed.
  • git diff --check — passed. Icon commit hooks: passed (Prettier, scoped Rust Clippy, and commit-message validation); TypeScript check skipped because this follow-up changes no TypeScript runtime code.
  • No frontend runtime code changed in the icon follow-up; live Dock/taskbar validation and Windows/Linux native runs were not performed.

macOS dev process-name verification

  • cargo test --manifest-path src-tauri/Cargo.toml --lib app::dev_process_name::tests -- --nocapture — 4 passed, including an actual re-exec with PID/argv/environment/cwd preservation and a rebuilt-inode replacement test. The existing linker unwind-size warning remains.
  • node --test scripts/dev/cleanup-orphans.test.cjs scripts/dev/tauri-dev-processes.test.cjs scripts/tauri/run-with-features.test.cjs — 15 passed. Cleanup uses fake process enumeration and kill commands; no user process is signaled by this regression test.
  • pnpm run check:test-placement and git diff --check — passed.
  • Process-name commit hooks: passed: formatting, scoped Rust Clippy, and commit-message validation; TypeScript skipped because no TypeScript files changed.
  • The native Dock tooltip itself was not inspected; no desktop UI control was used.

Screenshots

Fresh headless WebKit at 1280×800, signed out, without native Tauri IPC:

System light System dark
Light Dark
Dark CSS failure retains light Dark CSS timeout retains light
CSS failure CSS timeout

Development icon

Amber code-mark development icon

Artwork refinement: bracket geometry and stroke reduced, desktop assets regenerated with node scripts/tauri/dev-icons.mjs, and the 128px preview inspected. git diff --check passed; runtime code is unchanged.

@FresnelR27
FresnelR27 requested a review from beruro September 15, 2026 07:57
@beruro
beruro merged commit eb4037e into org2AI:develop Sep 15, 2026
16 checks passed
@Harry19081 Harry19081 added bug Something isn't working security Security-sensitive behavior, credentials, secrets, or advisories dev-tooling Developer tooling, build, CI, tests, diagnostics, or release labels Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dev-tooling Developer tooling, build, CI, tests, diagnostics, or release security Security-sensitive behavior, credentials, secrets, or advisories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants