Skip to content

Commit 0946f0a

Browse files
fix: keep upstream lint rules instead of fork suppressions (#120)
- providerAccountSync uses runtime's withEnvironmentRpcPermissions, so it no longer needs a no-rpc-permission-bypass exemption. - PeerMcpClient binds the caller's result schema before decoding, as upstream does. - The server build config reads the host through HostProcess. - The mobile thread screen builds the usage-limits report when it opens the panel, from the same provider instance it later renders with, so the composer no longer reads the clock and needs no react/purity suppression. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3c77b72 commit 0946f0a

6 files changed

Lines changed: 37 additions & 50 deletions

File tree

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ import {
2626
type ModelSelection,
2727
type ProviderInteractionMode,
2828
type ServerConfig as T3ServerConfig,
29-
type UsageLimitsReport,
3029
} from "@t3tools/contracts";
31-
import {
32-
collectProviderUsageLimits,
33-
hasProviderUsageLimits,
34-
isUsageLimitsCommand,
35-
} from "@t3tools/shared/usageLimits";
30+
import { hasProviderUsageLimits, isUsageLimitsCommand } from "@t3tools/shared/usageLimits";
3631
import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
3732
import type { ReactNode } from "react";
3833
import { useEffect, useEffectEvent, useRef, useState, type RefObject } from "react";
@@ -258,7 +253,8 @@ export interface ThreadComposerProps {
258253
followUp?: ActiveTurnComposerAction,
259254
stillSendable?: () => boolean,
260255
) => Promise<MessageId | null>;
261-
readonly onShowUsageLimits: (report: UsageLimitsReport | null) => void;
256+
/** Opens the limits panel; false when the provider reports none. */
257+
readonly onShowUsageLimits: () => boolean;
262258
readonly canSwitchProvider: boolean;
263259
readonly onUpdateInteractionMode?: (interactionMode: ProviderInteractionMode) => void;
264260
readonly onHeightChange?: (height: number) => void;
@@ -533,19 +529,11 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
533529
props.serverConfig?.usageLimitSources ?? [],
534530
);
535531
const openUsageLimits = () => {
536-
const report = collectProviderUsageLimits(
537-
props.selectedThread.runtime?.providerInstanceId ??
538-
props.selectedThread.modelSelection.instanceId,
539-
props.serverConfig?.providers ?? [],
540-
props.serverConfig?.usageLimitSources ?? [],
541-
// oxlint-disable-next-line react/purity -- The submit and menu handlers read usage limits only after a user action.
542-
Date.now(),
543-
);
544-
onShowUsageLimits(report);
545-
if (!report) {
532+
const shown = onShowUsageLimits();
533+
if (!shown) {
546534
Dialog.alert("Usage limits unavailable", "This provider does not currently report limits.");
547535
}
548-
return report !== null;
536+
return shown;
549537
};
550538

551539
const lockedProviderInstanceId = props.canSwitchProvider

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import type {
5353
RuntimeRequestId,
5454
ScopedThreadRef,
5555
ServerConfig as T3ServerConfig,
56-
UsageLimitsReport,
5756
RunId,
5857
} from "@t3tools/contracts";
5958
import {
@@ -1025,9 +1024,12 @@ function ThreadDetailBody(
10251024
readonly now: number;
10261025
} | null>(null);
10271026
// Approval/question identity invalidates quota: answering on any client resumes spending.
1027+
const usageLimitsInstanceId =
1028+
props.selectedThread.runtime?.providerInstanceId ??
1029+
props.selectedThread.modelSelection.instanceId;
10281030
const usageLimitsKey = [
10291031
selectedThreadKey,
1030-
props.selectedThread.modelSelection.instanceId,
1032+
usageLimitsInstanceId,
10311033
props.selectedThread.latestRun?.runId ?? "",
10321034
props.activePendingApproval?.requestId ?? props.activePendingUserInput?.requestId ?? "",
10331035
].join(":");
@@ -1037,22 +1039,25 @@ function ThreadDetailBody(
10371039
const usageLimitsReport =
10381040
usageLimitsPanel !== null && usageLimitsPanel.key === usageLimitsKey
10391041
? collectProviderUsageLimits(
1040-
props.selectedThread.modelSelection.instanceId,
1042+
usageLimitsInstanceId,
10411043
props.serverConfig?.providers ?? [],
10421044
props.serverConfig?.usageLimitSources ?? [],
10431045
usageLimitsPanel.now,
10441046
)
10451047
: null;
1046-
const showUsageLimits = (report: UsageLimitsReport | null) =>
1048+
const showUsageLimits = () => {
1049+
const now = Date.now();
1050+
const report = collectProviderUsageLimits(
1051+
usageLimitsInstanceId,
1052+
props.serverConfig?.providers ?? [],
1053+
props.serverConfig?.usageLimitSources ?? [],
1054+
now,
1055+
);
10471056
setUsageLimitsPanel(
1048-
report === null
1049-
? null
1050-
: {
1051-
key: usageLimitsKey,
1052-
threadKey: selectedThreadKey,
1053-
now: Date.parse(report.createdAt),
1054-
},
1057+
report === null ? null : { key: usageLimitsKey, threadKey: selectedThreadKey, now },
10551058
);
1059+
return report !== null;
1060+
};
10561061
const dismissUsageLimits = () => setUsageLimitsPanel(null);
10571062
// Late sends clear only their originating thread's limits panel.
10581063
const clearUsageLimitsFor = (threadKey: string) =>

‎apps/server/src/peer/PeerMcpClient.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,11 @@ const make = Effect.gen(function* () {
309309
}),
310310
);
311311
}
312+
const success = input.success;
312313
const decoded =
313314
body.result.structuredContent === undefined
314-
? // oxlint-disable-next-line t3code/no-inline-schema-compile -- Each caller supplies its tool's result schema.
315-
Schema.decodeEffect(Schema.fromJsonString(input.success))(text)
316-
: // oxlint-disable-next-line t3code/no-inline-schema-compile -- Each caller supplies its tool's result schema.
317-
Schema.decodeEffect(input.success)(body.result.structuredContent);
315+
? Schema.decodeEffect(Schema.fromJsonString(success))(text)
316+
: Schema.decodeEffect(success)(body.result.structuredContent);
318317
return yield* decoded.pipe(
319318
Effect.map(Result.succeed),
320319
Effect.mapError(

‎apps/server/vite.config.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import "vite-plus/test/config";
22
// @effect-diagnostics-next-line nodeBuiltinImport:off -- tsdown needs the asset path when it reads this config.
33
import * as NodePath from "node:path";
4+
import * as HostProcess from "@t3tools/shared/HostProcess";
5+
import * as Effect from "effect/Effect";
46
import { defineConfig, mergeConfig } from "vite-plus";
57

68
import baseConfig from "../../vite.config.ts";
@@ -46,10 +48,9 @@ const packExecutableTarget = resolveCliExecutableTarget({
4648
target: process.env.T3CODE_PACK_EXE_TARGET,
4749
nodeVersion: rootPackageJson.engines.node,
4850
hostNodeVersion: process.versions.node,
49-
// oxlint-disable-next-line t3code/no-global-process-runtime -- Build config selects the running Node binary, including its emulated architecture, before the Effect runtime exists.
50-
hostPlatform: process.platform,
51-
// oxlint-disable-next-line t3code/no-global-process-runtime -- Build config must match the Node binary's architecture rather than the machine's physical architecture.
52-
hostArch: process.arch,
51+
// The running Node is the one tsdown embeds for a native build.
52+
hostPlatform: Effect.runSync(HostProcess.Platform),
53+
hostArch: Effect.runSync(HostProcess.Architecture),
5354
});
5455

5556
// The root config's `projects` route repo-root runs to package configs,

‎packages/client-runtime/src/state/providerAccountSync.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ import {
2525
EnvironmentRpcUnavailableError,
2626
getInitialServerConfig,
2727
requestGuarded,
28-
RpcPermissionGuard,
2928
} from "../rpc/client.ts";
3029
import { createCommandPermissions } from "./commandPermissions.ts";
3130
import { resolveProviderInstanceDisplayName } from "./providerInstanceDisplay.ts";
32-
import { type AtomCommand, createAtomCommandScheduler, createRuntimeCommand } from "./runtime.ts";
31+
import {
32+
type AtomCommand,
33+
createAtomCommandScheduler,
34+
createRuntimeCommand,
35+
withEnvironmentRpcPermissions,
36+
} from "./runtime.ts";
3337

3438
export interface ProviderAccountSyncRequest {
3539
readonly sourceEnvironmentId: EnvironmentId;
@@ -242,16 +246,7 @@ export function createProviderAccountSyncCommand<E>(
242246
]),
243247
},
244248
execute: (request, atomRegistry) =>
245-
syncAccounts(request).pipe(
246-
Effect.provideService(RpcPermissionGuard, {
247-
authorize: (environmentId, method, payload) =>
248-
createCommandPermissions(runtime, method).authorize(
249-
atomRegistry,
250-
environmentId,
251-
payload,
252-
),
253-
}),
254-
),
249+
syncAccounts(request).pipe(withEnvironmentRpcPermissions(runtime, atomRegistry)),
255250
});
256251
return {
257252
...command,

‎vite.config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ export default defineConfig({
356356
files: [
357357
"packages/client-runtime/src/state/runtime.ts",
358358
"packages/client-runtime/src/state/vcsAction.ts",
359-
"packages/client-runtime/src/state/providerAccountSync.ts",
360359
],
361360
rules: {
362361
"t3code/no-rpc-permission-bypass": [

0 commit comments

Comments
 (0)