mark electron renderer for codex bridge
This commit is contained in:
parent
31a8e07a5b
commit
a54e847c8e
5 changed files with 82 additions and 17 deletions
|
|
@ -140,12 +140,13 @@
|
|||
<p class="hero-copy">
|
||||
Repaired the Electron desktop ChatGPT/Codex bridge after the Settings screen fell back to the
|
||||
browser-only “Desktop Required” state. The desktop shell now loads its preload bridge from a
|
||||
CommonJS file and stamps the renderer with an explicit Islandflow desktop user-agent marker.
|
||||
CommonJS file, exposes an explicit desktop runtime marker, and stamps the renderer with an
|
||||
Islandflow desktop user-agent marker.
|
||||
</p>
|
||||
<div class="meta-grid">
|
||||
<div class="meta-card"><span>Issue</span>islandflow-sc6</div>
|
||||
<div class="meta-card"><span>Scope</span>Electron desktop bridge loading</div>
|
||||
<div class="meta-card"><span>Validation</span>Desktop build and focused tests passed</div>
|
||||
<div class="meta-card"><span>Validation</span>Desktop build and focused tests passed; web build hit tracked shared-types blocker</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
|
|
@ -154,7 +155,7 @@
|
|||
<p>
|
||||
The Electron app was presenting the same fallback shown in a regular browser, which blocked managed
|
||||
ChatGPT login, Codex model loading, and native Copilot controls. The fix makes the preload file
|
||||
unambiguously runnable by Electron and gives the web runtime a reliable desktop shell signal while
|
||||
unambiguously runnable by Electron and gives the web runtime reliable desktop shell signals while
|
||||
the bridge is coming online.
|
||||
</p>
|
||||
</section>
|
||||
|
|
@ -163,9 +164,11 @@
|
|||
<h2>Changes Made</h2>
|
||||
<ul>
|
||||
<li>Added <code>apps/desktop/src/preload.cjs</code>, a CommonJS preload that exposes <code>window.islandflowDesktop.ai</code>.</li>
|
||||
<li>Exposed <code>window.islandflowDesktopRuntime</code> from preload as a minimal Electron shell marker.</li>
|
||||
<li>Updated the desktop build script to copy <code>src/preload.cjs</code> into <code>dist/preload.cjs</code>.</li>
|
||||
<li>Pointed the Electron <code>BrowserWindow</code> preload path at <code>preload.cjs</code> instead of <code>preload.js</code>.</li>
|
||||
<li>Added an explicit <code>IslandflowDesktop/<version> Electron/<version></code> user-agent token before loading the app URL.</li>
|
||||
<li>Updated the web runtime detector to accept the preload runtime marker and the Islandflow desktop user-agent token.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
|
@ -174,17 +177,19 @@
|
|||
<p>
|
||||
The visible failure mode was the Settings page labeling the session as browser-only even though it was
|
||||
running inside Islandflow Desktop. That meant the renderer saw neither the native preload bridge nor
|
||||
an Electron user-agent signature. The previous bridge code was emitted as <code>preload.js</code> inside
|
||||
a desktop-shell signal it trusted. The previous bridge code was emitted as <code>preload.js</code> inside
|
||||
an ESM package, which is fragile for Electron preload loading because the script is intended to run as
|
||||
classic CommonJS.
|
||||
classic CommonJS. The follow-up patch also protects against Electron user-agent stripping by using a
|
||||
dedicated preload marker.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Important Implementation Details</h2>
|
||||
<ul>
|
||||
<li>The preload bridge still exposes the same IPC methods, so the web UI contract did not change.</li>
|
||||
<li>The user-agent marker is a fallback signal, not the primary bridge. When the preload is healthy, <code>window.islandflowDesktop</code> remains the source of truth for native controls.</li>
|
||||
<li>The preload bridge still exposes the same IPC methods, so the native AI control contract did not change.</li>
|
||||
<li>The runtime marker is intentionally tiny: it says only that this renderer is Islandflow running in Electron.</li>
|
||||
<li>The user-agent marker is a secondary fallback signal. When the preload bridge is healthy, <code>window.islandflowDesktop</code> remains the source of truth for native controls.</li>
|
||||
<li>The app and Electron versions are read at runtime with <code>app.getVersion()</code> and <code>process.versions.electron</code>.</li>
|
||||
<li>The older TypeScript preload source remains in place for now, but Electron no longer depends on its emitted <code>.js</code> file.</li>
|
||||
</ul>
|
||||
|
|
@ -214,15 +219,20 @@ diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
|
|||
diff --git a/apps/desktop/src/preload.cjs b/apps/desktop/src/preload.cjs
|
||||
+const { contextBridge, ipcRenderer } = require("electron");
|
||||
+...
|
||||
+contextBridge.exposeInMainWorld("islandflowDesktopRuntime", {
|
||||
+ shell: "electron",
|
||||
+ app: "islandflow"
|
||||
+});
|
||||
+contextBridge.exposeInMainWorld("islandflowDesktop", bridge);</code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Expected Impact for End-Users</h2>
|
||||
<p>
|
||||
Opening Settings inside Islandflow Desktop should no longer show the browser-only fallback. Users should
|
||||
see the managed auth surface, connect ChatGPT or Codex, load managed models, and use native Copilot
|
||||
controls from the desktop app again.
|
||||
Opening Settings inside Islandflow Desktop should no longer show the browser-only fallback. If the
|
||||
native bridge itself is unavailable, users should see bridge recovery guidance instead of being told
|
||||
they are not in the desktop app. When the bridge is available, users should be able to connect ChatGPT
|
||||
or Codex, load managed models, and use native Copilot controls from the desktop app again.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
|
@ -231,23 +241,24 @@ diff --git a/apps/desktop/src/preload.cjs b/apps/desktop/src/preload.cjs
|
|||
<div class="validation-grid">
|
||||
<div class="validation-card good"><span>Build</span><code>bun --cwd=apps/desktop run build</code> passed.</div>
|
||||
<div class="validation-card good"><span>Desktop Tests</span><code>bun --cwd=apps/desktop run test</code> passed, 12 tests.</div>
|
||||
<div class="validation-card good"><span>Web Bridge Tests</span><code>bun test apps/web/app/desktop-ai.test.ts</code> passed, 17 tests.</div>
|
||||
<div class="validation-card good"><span>Web Bridge Tests</span><code>bun test apps/web/app/desktop-ai.test.ts</code> passed, 19 tests.</div>
|
||||
<div class="validation-card warn"><span>Web Build</span><code>bun --cwd=apps/web run build</code> compiled, then failed on tracked issue <code>islandflow-c8f</code>: shared <code>packages/types</code> imports still use explicit <code>.ts</code> extensions.</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Issues, Limitations, and Mitigations</h2>
|
||||
<ul>
|
||||
<li>The live GUI was not fully re-driven in this turn; validation focused on the build artifact and bridge detection tests.</li>
|
||||
<li>The live GUI screenshot after the first patch still showed the browser-only fallback, which prompted the explicit preload runtime marker added here.</li>
|
||||
<li>The old <code>src/preload.ts</code> still exists. A later cleanup can remove or consolidate it after confirming no packaging path still references it.</li>
|
||||
<li>An unrelated dirty file, <code>apps/web/next-env.d.ts</code>, was already present and was not touched by this fix.</li>
|
||||
<li>The web production build remains blocked by <code>islandflow-c8f</code>, unrelated to the desktop runtime marker change.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Follow-up Work</h2>
|
||||
<ul>
|
||||
<li>Close <code>islandflow-sc6</code> after the commit lands.</li>
|
||||
<li>Close <code>islandflow-sc6</code> after the follow-up commit lands.</li>
|
||||
<li>Consider adding a lightweight Electron smoke test that asserts <code>window.islandflowDesktop</code> exists after launch.</li>
|
||||
<li>Remove the unused TypeScript preload path once the CommonJS preload has been verified in packaged and dev runs.</li>
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue