Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
307db21
feat: auto-clear cache and recreate webview on server version change
jeanfbrito Apr 13, 2026
30667c0
fix: address review findings on cache-clear and webview-recreate paths
jeanfbrito Apr 13, 2026
e69e71f
revert: drop webview recreate path from cache-clear flow
jeanfbrito Apr 13, 2026
e842511
fix: guard auto cache-clear listener against uninitialized store
jeanfbrito Apr 28, 2026
309436e
fix: prevent lost build signal and double cache-clear on commit-hash …
jeanfbrito Apr 28, 2026
3685414
fix: propagate buildIdSource to prevent migration miss and version-st…
jeanfbrito Apr 28, 2026
268f926
fix(cache): handle version-source legacy baseline and wrap clear fail…
jeanfbrito Apr 28, 2026
f55cac9
feat: add Meteor Autoupdate as third bundle-version signal source
jeanfbrito Apr 28, 2026
1a4abf5
fix(servers): split lastServerBuildId into per-source baselines
jeanfbrito Apr 28, 2026
14488e4
fix: close legacy-listener race and document cache_version cookie
jeanfbrito Apr 28, 2026
8363000
fix(cache): hoist cacheVersion mismatch check above source-specific p…
jeanfbrito Apr 28, 2026
b26701a
fix(smart-cache-clear): address four auditor-surfaced bugs (C2/H1+M3/…
jeanfbrito Apr 28, 2026
1a95af4
fix(cache-clear): queue in-flight signals and fix RC version comparison
jeanfbrito Apr 28, 2026
2da0a6a
fix(cache): always dispatch on autoupdate signal; latest-wins pending…
jeanfbrito Apr 28, 2026
07c4f9f
fix(autoupdate): edge-trigger guard prevents infinite reload loop
jeanfbrito Apr 28, 2026
4b5f0cb
fix(smart-cache-clear): sentinel-aware autoupdate comparison in main …
jeanfbrito Apr 28, 2026
610ff9c
test: tighten sentinel regex and add rejection cases
jeanfbrito Apr 28, 2026
a3f50c2
refactor(cache-clear): per-source pendingClears Map in main.ts (F1)
jeanfbrito Apr 28, 2026
e3f66d0
refactor(cache-clear): retire legacy WEBVIEW_GIT_COMMIT_HASH_CHECK li…
jeanfbrito Apr 28, 2026
b9cbcb2
fix: clear on first autoupdate observation, not adopt
jeanfbrito Apr 28, 2026
31d3d3a
fix: prevent repeated smart cache clears
jeanfbrito Apr 29, 2026
3be1cee
fix(cache-clear): align preload slotKey with main pendingKey
jeanfbrito Apr 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .knowledge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pending/
60 changes: 60 additions & 0 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ const start = async () => {
titleUpdates: false,
userLoginDetection: false,
gitCommitHash: false,
autoupdateSetup: false,
themeAppearance: false,
userPresence: false,
};
Expand Down Expand Up @@ -542,6 +543,65 @@ const start = async () => {
setupFlags.gitCommitHash = true;
}

// Meteor Autoupdate: observe when the server pushes a new client bundle.
// When newClientAvailable() becomes true, read the new bundle version and
// notify the desktop so it can decide whether to clear cache + reload.
// Falls back silently when Autoupdate is not present (older RC versions).
if (Tracker && !setupFlags.autoupdateSetup) {
try {
const { Autoupdate } = window as any;
if (Autoupdate && typeof Autoupdate.newClientAvailable === 'function') {
// Edge-trigger guard: when the private Meteor store cannot supply a
// real bundle version we must NOT dispatch on every autorun re-fire
// (Tracker re-runs after each reload while newClientAvailable stays
// true and the store stays broken → infinite clear+reload loop).
// Fire at most once per false→true edge; reset when available drops
// back to false so the next true-edge can fire again.
let unknownBundleSent = false;

Tracker.autorun(() => {
const available = Autoupdate.newClientAvailable();

if (!available) {
// Re-arm: next true-edge is allowed to dispatch.
unknownBundleSent = false;
return;
}

let bundleVersion: string | undefined;
try {
const store =
Meteor?.connection?._stores?.meteor_autoupdate_clientVersions;
const doc =
store?.get?.('version-refreshable') ?? store?.get?.('version');
bundleVersion = doc?.version ?? doc?._id;
} catch {
// store access failed — fall through to the no-version path below
}

if (bundleVersion) {
// Concrete version available — dispatch unconditionally (each
// distinct version string is its own edge in the main process).
window.RocketChatDesktop.notifyBundleAutoupdate?.({
bundleVersion,
});
return;
}

// No version yet — emit at most once per true-edge to avoid the
// infinite-reload loop described in the edge-trigger contract above.
if (!unknownBundleSent) {
unknownBundleSent = true;
window.RocketChatDesktop.notifyBundleAutoupdate?.({});
}
});
setupFlags.autoupdateSetup = true;
}
} catch {
// Autoupdate not available — silently skip
}
}

if (Tracker && Meteor && getUserPreference && !setupFlags.userPresence) {
Tracker.autorun(() => {
const uid = Meteor.userId();
Expand Down
2 changes: 2 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { JitsiMeetElectron } from './jitsi/preload';
import { listenToNotificationsRequests } from './notifications/preload';
import { listenToScreenSharingRequests } from './screenSharing/preload';
import { RocketChatDesktop } from './servers/preload/api';
import { flushPendingBuildSignal } from './servers/preload/serverBuild';
import { setServerUrl } from './servers/preload/urls';
import { createRendererReduxStore, listen } from './store';
import { WEBVIEW_DID_NAVIGATE } from './ui/actions';
Expand Down Expand Up @@ -61,6 +62,7 @@ const start = async (): Promise<void> => {
await whenReady();

await createRendererReduxStore();
flushPendingBuildSignal();

await invoke('server-view/ready');

Expand Down
Loading
Loading