The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 10:15 UTC
refactor(shared): keep persisted settings helpers private (#10004)
Julius Marminge committed
Sep 5, 2026 at 00:26 UTC
1584076d7651278863f7ee90f5bf70c2aba981b3
2 files changed
+15
-24
packages/shared/src/serverSettings.test.ts
+13
-22
@@ -11,43 +11,34 @@ import { resolveServerBackgroundActivitySettings } from "./backgroundActivitySet
11
import { createModelSelection } from "./model.ts";
12
import {
13
applyServerSettingsPatch,
14
- extractPersistedServerObservabilitySettings,
14
isModelSelectionProviderEnabled,
16
- normalizePersistedServerSettingString,
15
parsePersistedServerObservabilitySettings,
16
resolveSourceControlWriterModelSelection,
17
} from "./serverSettings.ts";
18
19
describe("serverSettings helpers", () => {
22
- it("normalizes optional persisted strings", () => {
23
- expect(normalizePersistedServerSettingString(undefined)).toBeUndefined();
24
- expect(normalizePersistedServerSettingString(" ")).toBeUndefined();
25
- expect(normalizePersistedServerSettingString(" http://localhost:4318/v1/traces ")).toBe(
26
- "http://localhost:4318/v1/traces",
27
- );
28
- });
29
-
30
- it("extracts persisted observability settings", () => {
20
+ it("ignores missing and blank persisted observability URLs", () => {
21
+ expect(parsePersistedServerObservabilitySettings("{}")).toEqual({
22
+ otlpTracesUrl: undefined,
23
+ otlpMetricsUrl: undefined,
24
+ });
25
expect(
32
- extractPersistedServerObservabilitySettings({
33
- observability: {
34
- otlpTracesUrl: " http://localhost:4318/v1/traces ",
35
- otlpMetricsUrl: " http://localhost:4318/v1/metrics ",
36
- },
37
- }),
26
+ parsePersistedServerObservabilitySettings(
27
+ JSON.stringify({ observability: { otlpTracesUrl: " ", otlpMetricsUrl: "" } }),
28
+ ),
29
).toEqual({
39
- otlpTracesUrl: "http://localhost:4318/v1/traces",
40
- otlpMetricsUrl: "http://localhost:4318/v1/metrics",
30
+ otlpTracesUrl: undefined,
31
+ otlpMetricsUrl: undefined,
32
});
33
});
34
44
- it("parses lenient persisted settings JSON", () => {
35
+ it("parses lenient persisted settings JSON and trims observability URLs", () => {
36
expect(
37
parsePersistedServerObservabilitySettings(
38
JSON.stringify({
39
observability: {
49
- otlpTracesUrl: "http://localhost:4318/v1/traces",
50
- otlpMetricsUrl: "http://localhost:4318/v1/metrics",
40
+ otlpTracesUrl: " http://localhost:4318/v1/traces ",
41
+ otlpMetricsUrl: " http://localhost:4318/v1/metrics ",
42
},
43
}),
44
),
packages/shared/src/serverSettings.ts
+2
-2
@@ -69,14 +69,14 @@ export interface PersistedServerObservabilitySettings {
69
readonly otlpMetricsUrl: string | undefined;
70
}
71
72
-export function normalizePersistedServerSettingString(
72
+function normalizePersistedServerSettingString(
73
value: string | null | undefined,
74
): string | undefined {
75
const trimmed = value?.trim();
76
return trimmed && trimmed.length > 0 ? trimmed : undefined;
77
}
78
79
-export function extractPersistedServerObservabilitySettings(input: {
79
+function extractPersistedServerObservabilitySettings(input: {
80
readonly observability?: {
81
readonly otlpTracesUrl?: string;
82
readonly otlpMetricsUrl?: string;