Skip to content

Commit f57c85f

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-32430
2 parents 7ca1913 + c864b1c commit f57c85f

37 files changed

Lines changed: 1411 additions & 191 deletions

‎apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ function ProviderAccount({
149149
const complete = useAtomCommand(serverEnvironment.completeProviderAuth, options);
150150
const cancel = useAtomCommand(serverEnvironment.cancelProviderAuth, options);
151151
const logout = useAtomCommand(serverEnvironment.logoutProviderAuth, options);
152+
const removeMethod = useAtomCommand(serverEnvironment.removeProviderAuthMethod, options);
153+
const canRemoveMethod = useAtomValue(
154+
serverEnvironment.removeProviderAuthMethod.permissionAtom(environmentId),
155+
);
152156
// Matches ListRowLayout: large text stacks the action below instead of squeezing the status.
153157
const stacked = useWindowDimensions().fontScale >= 1.5;
154158
const [pending, setPending] = useState(false);
@@ -260,6 +264,21 @@ function ProviderAccount({
260264
id: `method:${method.id}`,
261265
title: method.name,
262266
}));
267+
const removableMethods = methods.filter((method) => method.canRemove);
268+
const removeActions: MenuAction[] = removableMethods.length
269+
? [
270+
{
271+
id: "remove",
272+
title: "Remove incomplete connection",
273+
attributes: { disabled: disabled || active || !canRemoveMethod },
274+
subactions: removableMethods.map((method) => ({
275+
id: `remove:${method.id}`,
276+
title: method.name,
277+
attributes: { destructive: true, disabled: disabled || active || !canRemoveMethod },
278+
})),
279+
},
280+
]
281+
: [];
263282
function startSignIn(methodId?: string) {
264283
void run(() => start(methodId ? { environmentId, input: { instanceId, methodId } } : target));
265284
}
@@ -283,10 +302,16 @@ function ProviderAccount({
283302
if (id === "signOut") signOut();
284303
// iOS keeps a disabled submenu's children selectable, so sign-in guards here too.
285304
else if (signInDisabled) return;
286-
else if (id.startsWith("method:")) startSignIn(id.slice("method:".length));
305+
else if (id.startsWith("remove:")) {
306+
if (active || !canRemoveMethod) return;
307+
const methodId = id.slice("remove:".length);
308+
if (!removableMethods.some((method) => method.id === methodId)) return;
309+
void run(() => removeMethod({ environmentId, input: { instanceId, methodId } }));
310+
} else if (id.startsWith("method:")) startSignIn(id.slice("method:".length));
287311
else if (id === "change") startSignIn();
288312
}
289313
const accountActions: MenuAction[] = [
314+
...removeActions,
290315
...(canSignIn
291316
? [
292317
{
@@ -357,7 +382,7 @@ function ProviderAccount({
357382
accessibilityRole="button"
358383
accessibilityLabel={`Sign in to ${name}`}
359384
title="Sign in with"
360-
actions={methodActions}
385+
actions={[...methodActions, ...removeActions]}
361386
onPressAction={({ nativeEvent }) => onMenuAction(nativeEvent.event)}
362387
>
363388
<ControlPill variant="primary" label="Sign in" accessibilityLabel={`Sign in to ${name}`} />

‎apps/server/src/auth/RpcAuthorization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const RPC_REQUIRED_SCOPES = {
7474
[WS_METHODS.chatGptHandoffSubscribe]: AuthProvidersManageScope,
7575
[WS_METHODS.providerAuthRespond]: AuthProvidersManageScope,
7676
[WS_METHODS.providerAuthCancel]: AuthProvidersManageScope,
77+
[WS_METHODS.providerAuthRemoveMethod]: AuthProvidersManageScope,
7778
[WS_METHODS.providerAuthLogout]: AuthProvidersManageScope,
7879
[WS_METHODS.providerAuthSubscribe]: AuthProvidersManageScope,
7980
[WS_METHODS.providerInstallStart]: AuthProvidersManageScope,

‎apps/server/src/environmentTheme.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
125125
withEnvironmentThemes(
126126
{
127127
"nightfall.json": encodeThemeFile(NIGHTFALL_THEME),
128+
"notepad.json": `\uFEFF${encodeThemeFile(SHARED_THEME)}`,
128129
"unresolved.json":
129130
'{ "name": "X", "appearance": "dark", "canvas": "{{ background }}", "accent": "#7aa2f7" }',
130131
"malformed.json": "{ not json",
@@ -137,7 +138,7 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
137138
Effect.gen(function* () {
138139
assert.deepEqual(
139140
(yield* currentThemes).map((theme) => theme.id),
140-
["nightfall"],
141+
["nightfall", "notepad"],
141142
);
142143
}),
143144
),

‎apps/server/src/environmentTheme.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export const readThemeFileGuarded = (filePath: string, maxBytes: number): string
8080
if (read <= 0) break;
8181
offset += read;
8282
}
83-
return contents.subarray(0, offset).toString("utf8");
83+
// Unlike Buffer#toString, TextDecoder drops a UTF-8 BOM, which JSON.parse rejects.
84+
return new TextDecoder().decode(contents.subarray(0, offset));
8485
} catch {
8586
return null;
8687
} finally {

‎apps/server/src/observability/RpcInstrumentation.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const RPC_AGGREGATES = {
4646
[WS_METHODS.chatGptHandoffSubscribe]: "provider",
4747
[WS_METHODS.providerAuthRespond]: "provider",
4848
[WS_METHODS.providerAuthCancel]: "provider",
49+
[WS_METHODS.providerAuthRemoveMethod]: "provider",
4950
[WS_METHODS.providerAuthLogout]: "provider",
5051
[WS_METHODS.providerAuthSubscribe]: "provider",
5152
[WS_METHODS.providerInstallStart]: "provider",

0 commit comments

Comments
 (0)