Roo-Code/packages/cloud/src/StaticSettingsService.ts
John Richmond 80af39dc74
separate task sync roomote control (#7799)
* feat: separate Task Sync and Roomote Control settings

- Add new taskSyncEnabled setting to control task content syncing
- Keep remoteControlEnabled for Roomote Control functionality
- Task Sync controls whether task content is sent to cloud
- Roomote Control controls whether cloud can send instructions back
- Roomote Control now depends on Task Sync being enabled
- Usage metrics (tokens, cost) always reported regardless of settings
- Update UI with two separate toggles and clear descriptions
- Add info text explaining usage metrics are always reported

* feat: add missing translations for Task Sync and Roomote Control settings

- Added taskSync, taskSyncDescription, remoteControlRequiresTaskSync, and usageMetricsAlwaysReported keys to all non-English cloud.json files
- Updated cloudBenefit keys to match English structure
- Ensured all languages have consistent translation keys for the new Task Sync and Roomote Control features

* Cloud: cleanup taskSyncEnabled additions

* fix: correct indentation localization files

---------

Co-authored-by: Roo Code <roomote@roocode.com>
2025-09-10 12:43:11 -07:00

85 lines
2.1 KiB
TypeScript

import {
type SettingsService,
type UserFeatures,
type UserSettingsConfig,
type UserSettingsData,
OrganizationAllowList,
OrganizationSettings,
organizationSettingsSchema,
ORGANIZATION_ALLOW_ALL,
} from "@roo-code/types"
export class StaticSettingsService implements SettingsService {
private settings: OrganizationSettings
private log: (...args: unknown[]) => void
constructor(envValue: string, log?: (...args: unknown[]) => void) {
this.log = log || console.log
this.settings = this.parseEnvironmentSettings(envValue)
}
private parseEnvironmentSettings(envValue: string): OrganizationSettings {
try {
const decodedValue = Buffer.from(envValue, "base64").toString("utf-8")
const parsedJson = JSON.parse(decodedValue)
return organizationSettingsSchema.parse(parsedJson)
} catch (error) {
this.log(
`[StaticSettingsService] failed to parse static settings: ${error instanceof Error ? error.message : String(error)}`,
error,
)
throw new Error("Failed to parse static settings", { cause: error })
}
}
public getAllowList(): OrganizationAllowList {
return this.settings?.allowList || ORGANIZATION_ALLOW_ALL
}
public getSettings(): OrganizationSettings | undefined {
return this.settings
}
/**
* Returns static user settings with roomoteControlEnabled and extensionBridgeEnabled as true
*/
public getUserSettings(): UserSettingsData | undefined {
return {
features: {
roomoteControlEnabled: true,
},
settings: {
extensionBridgeEnabled: true,
taskSyncEnabled: true,
},
version: 1,
}
}
public getUserFeatures(): UserFeatures {
return {
roomoteControlEnabled: true,
}
}
public getUserSettingsConfig(): UserSettingsConfig {
return {
extensionBridgeEnabled: true,
taskSyncEnabled: true,
}
}
public async updateUserSettings(_settings: Partial<UserSettingsConfig>): Promise<boolean> {
throw new Error("User settings updates are not supported in static mode")
}
public isTaskSyncEnabled(): boolean {
// Static settings always enable task sync
return true
}
public dispose(): void {
// No resources to clean up for static settings.
}
}