@@ -61,3 +61,71 @@ After that, you can copy the dist/ directory to your server and serve it.
6161
6262* To deploy on subdirectory, you need to rebuild the app youself after updating the ` base ` path in [ ` build.config.ts ` ] ( build.config.ts ) .
6363 * For example, if you want to deploy on ` https://sable.moe/app ` , then set ` base: '/app' ` .
64+
65+ ## SW session resync configuration
66+
67+ Sable can automatically resync the Matrix session token held by the service worker in the
68+ background. This keeps push notifications and background sync working even after long idle
69+ periods where a browser or OS may have killed the service worker.
70+
71+ Add a ` sessionSync ` block to ` config.json ` to configure the behaviour:
72+
73+ ``` json
74+ {
75+ "sessionSync" : {
76+ "phase1ForegroundResync" : true ,
77+ "phase2VisibleHeartbeat" : false ,
78+ "phase3AdaptiveBackoffJitter" : false ,
79+ "foregroundDebounceMs" : 1500 ,
80+ "heartbeatIntervalMs" : 600000 ,
81+ "resumeHeartbeatSuppressMs" : 60000 ,
82+ "heartbeatMaxBackoffMs" : 1800000
83+ }
84+ }
85+ ```
86+
87+ | Field | Type | Default | Description |
88+ | ---| ---| ---| ---|
89+ | ` phase1ForegroundResync ` | boolean | ` false ` | Push session token to the SW when the app returns to the foreground (debounced) |
90+ | ` phase2VisibleHeartbeat ` | boolean | ` false ` | Periodically push the session token while the app is visible |
91+ | ` phase3AdaptiveBackoffJitter ` | boolean | ` false ` | Back off exponentially with jitter when heartbeat pushes fail |
92+ | ` foregroundDebounceMs ` | number | ` 1500 ` | Milliseconds to debounce foreground resync events |
93+ | ` heartbeatIntervalMs ` | number | ` 600000 ` | Milliseconds between heartbeat pushes (default: 10 min) |
94+ | ` resumeHeartbeatSuppressMs ` | number | ` 60000 ` | Suppress heartbeat for this many ms immediately after a foreground resync |
95+ | ` heartbeatMaxBackoffMs ` | number | ` 1800000 ` | Maximum backoff interval under phase 3 (default: 30 min) |
96+
97+ Each phase builds on the previous one. A typical starting deployment enables only
98+ ` phase1ForegroundResync ` ; phases 2 and 3 add more aggressive keep-alive behaviour
99+ suitable for users who leave the app open in a background tab.
100+
101+ ### Controlled rollout with experiments
102+
103+ To roll out session sync gradually, combine the ` sessionSync ` block with an
104+ ` experiments.sessionSyncStrategy ` entry:
105+
106+ ``` json
107+ {
108+ "sessionSync" : {
109+ "phase1ForegroundResync" : true ,
110+ "phase2VisibleHeartbeat" : true ,
111+ "phase3AdaptiveBackoffJitter" : false
112+ },
113+ "experiments" : {
114+ "sessionSyncStrategy" : {
115+ "enabled" : true ,
116+ "rolloutPercentage" : 20 ,
117+ "controlVariant" : " control" ,
118+ "variants" : [" session-sync-heartbeat" , " session-sync-adaptive" ]
119+ }
120+ }
121+ }
122+ ```
123+
124+ When this experiment is active, users bucketed into ` session-sync-heartbeat ` get phases 1
125+ and 2; users bucketed into ` session-sync-adaptive ` get all three phases; users in the
126+ control group get no session sync regardless of the ` sessionSync ` flags. Set
127+ ` rolloutPercentage: 0 ` or ` enabled: false ` to disable the experiment and fall back to the
128+ raw ` sessionSync ` flags for everyone.
129+
130+ See [ Feature flag and experiment configuration] ( #feature-flag-and-experiment-configuration )
131+ for the full experiments schema.
0 commit comments