44 DEFAULT_BACKGROUND_ACTIVITY_PROFILE ,
55 DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL ,
66 DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL ,
7+ DEFAULT_PULL_REQUEST_LOOKUP_INTERVAL ,
78 type ServerSettings ,
89} from "@t3tools/contracts" ;
910import * as Duration from "effect/Duration" ;
@@ -12,6 +13,8 @@ export interface ResolvedBackgroundActivitySettings {
1213 readonly profile : BackgroundActivityProfile ;
1314 readonly automaticGitFetchInterval : Duration . Duration ;
1415 readonly providerHealthRefreshInterval : Duration . Duration ;
16+ /** How long a branch keeps its last pull request lookup before the hosting CLI is asked again. */
17+ readonly pullRequestLookupInterval : Duration . Duration ;
1518 readonly hostPowerMonitorActiveInterval : Duration . Duration ;
1619 readonly hostPowerMonitorIdleInterval : Duration . Duration ;
1720 readonly idleClientTtl : Duration . Duration ;
@@ -26,6 +29,7 @@ const PRESET_SETTINGS: Record<BackgroundActivityProfile, ResolvedBackgroundActiv
2629 profile : "performance" ,
2730 automaticGitFetchInterval : Duration . seconds ( 15 ) ,
2831 providerHealthRefreshInterval : Duration . minutes ( 1 ) ,
32+ pullRequestLookupInterval : Duration . minutes ( 1 ) ,
2933 hostPowerMonitorActiveInterval : Duration . seconds ( 30 ) ,
3034 hostPowerMonitorIdleInterval : Duration . minutes ( 2 ) ,
3135 idleClientTtl : Duration . seconds ( 45 ) ,
@@ -38,6 +42,7 @@ const PRESET_SETTINGS: Record<BackgroundActivityProfile, ResolvedBackgroundActiv
3842 profile : "balanced" ,
3943 automaticGitFetchInterval : DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL ,
4044 providerHealthRefreshInterval : DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL ,
45+ pullRequestLookupInterval : DEFAULT_PULL_REQUEST_LOOKUP_INTERVAL ,
4146 hostPowerMonitorActiveInterval : Duration . seconds ( 30 ) ,
4247 hostPowerMonitorIdleInterval : Duration . minutes ( 5 ) ,
4348 idleClientTtl : Duration . seconds ( 45 ) ,
@@ -50,6 +55,7 @@ const PRESET_SETTINGS: Record<BackgroundActivityProfile, ResolvedBackgroundActiv
5055 profile : "battery-saver" ,
5156 automaticGitFetchInterval : Duration . seconds ( 0 ) ,
5257 providerHealthRefreshInterval : Duration . minutes ( 15 ) ,
58+ pullRequestLookupInterval : Duration . minutes ( 15 ) ,
5359 hostPowerMonitorActiveInterval : Duration . minutes ( 1 ) ,
5460 hostPowerMonitorIdleInterval : Duration . minutes ( 10 ) ,
5561 idleClientTtl : Duration . seconds ( 45 ) ,
@@ -87,6 +93,8 @@ export function resolveBackgroundActivitySettings(
8793 overrides . automaticGitFetchInterval ?? preset . automaticGitFetchInterval ,
8894 providerHealthRefreshInterval :
8995 overrides . providerHealthRefreshInterval ?? preset . providerHealthRefreshInterval ,
96+ pullRequestLookupInterval :
97+ overrides . pullRequestLookupInterval ?? preset . pullRequestLookupInterval ,
9098 hostPowerMonitorActiveInterval :
9199 overrides . hostPowerMonitorActiveInterval ?? preset . hostPowerMonitorActiveInterval ,
92100 hostPowerMonitorIdleInterval :
@@ -110,6 +118,7 @@ function resolvedSettingsEqual(
110118 return (
111119 durationsEqual ( a . automaticGitFetchInterval , b . automaticGitFetchInterval ) &&
112120 durationsEqual ( a . providerHealthRefreshInterval , b . providerHealthRefreshInterval ) &&
121+ durationsEqual ( a . pullRequestLookupInterval , b . pullRequestLookupInterval ) &&
113122 durationsEqual ( a . hostPowerMonitorActiveInterval , b . hostPowerMonitorActiveInterval ) &&
114123 durationsEqual ( a . hostPowerMonitorIdleInterval , b . hostPowerMonitorIdleInterval ) &&
115124 durationsEqual ( a . idleClientTtl , b . idleClientTtl ) &&
@@ -160,6 +169,9 @@ export function normalizeBackgroundActivitySettings(
160169 )
161170 ? { providerHealthRefreshInterval : resolved . providerHealthRefreshInterval }
162171 : { } ) ,
172+ ...( ! durationsEqual ( resolved . pullRequestLookupInterval , preset . pullRequestLookupInterval )
173+ ? { pullRequestLookupInterval : resolved . pullRequestLookupInterval }
174+ : { } ) ,
163175 ...( ! durationsEqual (
164176 resolved . hostPowerMonitorActiveInterval ,
165177 preset . hostPowerMonitorActiveInterval ,
@@ -258,6 +270,7 @@ export function normalizeServerBackgroundActivitySettings(
258270 overrides : {
259271 automaticGitFetchInterval : resolved . automaticGitFetchInterval ,
260272 providerHealthRefreshInterval : resolved . providerHealthRefreshInterval ,
273+ pullRequestLookupInterval : resolved . pullRequestLookupInterval ,
261274 hostPowerMonitorActiveInterval : resolved . hostPowerMonitorActiveInterval ,
262275 hostPowerMonitorIdleInterval : resolved . hostPowerMonitorIdleInterval ,
263276 idleClientTtl : resolved . idleClientTtl ,
0 commit comments