Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(mobile): reconnect environments immediately on resume #4878

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/4878/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 13 changed files with 77 additions and 11 deletions (loading 10).

x
0 of 13 viewed, 13 left
21 additions and 0 deletionsapps/mobile/src/connection/app-state-wakeups.test.tsAdded
View file
@@ -0,0 +1,21 @@
+import { describe, expect, it } from "@effect/vitest";
+​
+import {
+ MOBILE_BACKGROUND_RECONNECT_AFTER_MS,
+ mobileApplicationActiveWakeup,
+} from "./app-state-wakeups";
+​
+describe("mobileApplicationActiveWakeup", () => {
+ it("uses a fast probe after a short interruption", () => {
+ expect(mobileApplicationActiveWakeup(null, 20_000)).toBe("application-active-probe");
+ expect(
+ mobileApplicationActiveWakeup(20_000, 20_000 + MOBILE_BACKGROUND_RECONNECT_AFTER_MS - 1),
+ ).toBe("application-active-probe");
+ });
+​
+ it("replaces the session after a meaningful background suspension", () => {
+ expect(
+ mobileApplicationActiveWakeup(20_000, 20_000 + MOBILE_BACKGROUND_RECONNECT_AFTER_MS),
+ ).toBe("application-active-reconnect");
+ });
+});
18 additions and 0 deletionsapps/mobile/src/connection/app-state-wakeups.tsAdded
View file
@@ -0,0 +1,18 @@
+import type { Wakeups } from "@t3tools/client-runtime/connection";
+​
+export const MOBILE_BACKGROUND_RECONNECT_AFTER_MS = 10_000;
+​
+export type MobileApplicationActiveWakeup = Extract<
+ Wakeups.ConnectionWakeup,