TL;DR: Project tab order resets on every restart because the Language Server binds to a random port, changing the Chromium origin and wiping localStorage. The getPersistentPort() function in main.js has never worked. Fix is a 2-line change using Electron’s session.partition.
The Problem
When you rearrange project tabs in the Antigravity sidebar and restart the app, the tab order resets to default. This has been happening since v2.0.0 and still occurs on v2.0.11.
Root Cause
The Language Server starts with --https_server_port 0, which tells the OS to assign a random port. The browser window loads https://127.0.0.1``:<random_port>/, and since Chromium scopes localStorage per-origin (including port), a new port = a new origin = empty localStorage.
Evidence from my Electron logs — three consecutive launches:
[18:00:23] Local: https://127.0.0.1:60021/
[18:21:06] Local: https://127.0.0.1:64189/
[18:21:18] Local: https://127.0.0.1:55837/
All three show "Starting app with dynamic port…" in the log, meaning getPersistentPort() returned 0 every time. I checked the full log history — every single startup from v2.0.0 through v2.0.11 falls through to the dynamic port fallback. The function exists in the codebase but has never successfully persisted a port.
Fix (verified, working)
Instead of trying to fix port persistence, use Electron’s named session.partition to decouple localStorage from the origin entirely:
1. utils.js — createWindow(), add partition to webPreferences:
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path_1.default.join(__dirname, 'preload.js'),
+ partition: 'persist:antigravity',
},
2. languageServer.js — setupLocalCertTrust(), apply cert trust to partition session:
function setupLocalCertTrust() {
- session.defaultSession.setCertificateVerifyProc((request, callback) => {
- if (...) { callback(0); } else { callback(-3); }
- });
+ const certVerifyProc = (request, callback) => {
+ if (...) { callback(0); } else { callback(-3); }
+ };
+ session.defaultSession.setCertificateVerifyProc(certVerifyProc);
+ session.fromPartition('persist:antigravity')
+ .setCertificateVerifyProc(certVerifyProc);
}
The persist: prefix tells Electron to write session data to disk. Without the cert trust change on the partition session, the browser window gets an SSL error loading the Language Server’s self-signed HTTPS endpoint.
Why This Works
-
Electron’s
persist:partitions storelocalStorage, cookies, and cache in a folder keyed by partition name — not by origin -
The partition name is constant (
persist:antigravity), so data survives port changes -
This is a standard Electron pattern for apps with dynamic URLs
Environment
-
Antigravity: v2.0.11 (bug present since v2.0.0)
-
OS: Windows 11
-
Electron logs:
%APPDATA%\Antigravity\logs\main.log
I patched my local app.asar with this fix and can confirm project tab order now persists across restarts. Happy to provide any additional details.