Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a202840d29 | ||
|
|
d9e49e4500 | ||
|
|
3062967d05 | ||
|
|
4f0f24f055 | ||
|
|
d1e85c4e8f |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/desktop",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "dist-electron/main.cjs",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "t3",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -41,7 +41,8 @@ describe("VcsProjectConfig", () => {
|
||||
yield* fileSystem.makeDirectory(nested, { recursive: true });
|
||||
yield* fileSystem.writeFileString(
|
||||
path.join(configDir, "vcs.json"),
|
||||
'{"vcs":{"kind":"jj"}}',
|
||||
// @effect-diagnostics-next-line preferSchemaOverJson:off
|
||||
JSON.stringify({ vcs: { kind: "jj" } }),
|
||||
);
|
||||
|
||||
const config = yield* VcsProjectConfig.VcsProjectConfig;
|
||||
@@ -66,24 +67,4 @@ describe("VcsProjectConfig", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.layer(TestLayer)("falls back to auto when config JSON is invalid", (it) => {
|
||||
it.effect("returns auto", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const root = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-vcs-config-test-",
|
||||
});
|
||||
const configDir = path.join(root, ".t3code");
|
||||
yield* fileSystem.makeDirectory(configDir, { recursive: true });
|
||||
yield* fileSystem.writeFileString(path.join(configDir, "vcs.json"), "{invalid-json");
|
||||
|
||||
const config = yield* VcsProjectConfig.VcsProjectConfig;
|
||||
const kind = yield* config.resolveKind({ cwd: root });
|
||||
|
||||
assert.equal(kind, "auto");
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,6 @@ import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
@@ -16,9 +15,16 @@ const ProjectVcsConfig = Schema.Struct({
|
||||
),
|
||||
vcsKind: Schema.optional(VcsDriverKind),
|
||||
});
|
||||
const decodeProjectVcsConfig = Schema.decodeUnknownOption(Schema.fromJsonString(ProjectVcsConfig));
|
||||
const isProjectVcsConfig = Schema.is(ProjectVcsConfig);
|
||||
|
||||
type ProjectVcsConfigFile = typeof ProjectVcsConfig.Type;
|
||||
interface ProjectVcsConfigFile {
|
||||
readonly vcs?:
|
||||
| {
|
||||
readonly kind?: VcsDriverKindType | undefined;
|
||||
}
|
||||
| undefined;
|
||||
readonly vcsKind?: VcsDriverKindType | undefined;
|
||||
}
|
||||
|
||||
export interface VcsProjectConfigResolveInput {
|
||||
readonly cwd: string;
|
||||
@@ -39,8 +45,14 @@ function configuredKind(config: ProjectVcsConfigFile): VcsDriverKindType | "auto
|
||||
return config.vcs?.kind ?? config.vcsKind ?? "auto";
|
||||
}
|
||||
|
||||
const parseConfig = (raw: string): Option.Option<ProjectVcsConfigFile> =>
|
||||
decodeProjectVcsConfig(raw);
|
||||
function parseConfig(raw: string): ProjectVcsConfigFile | null {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as unknown;
|
||||
return isProjectVcsConfig(parsed) ? parsed : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export const make = Effect.fn("makeVcsProjectConfig")(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
@@ -51,12 +63,12 @@ export const make = Effect.fn("makeVcsProjectConfig")(function* () {
|
||||
while (true) {
|
||||
const candidate = path.join(current, ".t3code", "vcs.json");
|
||||
if (yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false))) {
|
||||
return Option.some(candidate);
|
||||
return candidate;
|
||||
}
|
||||
|
||||
const parent = path.dirname(current);
|
||||
if (parent === current) {
|
||||
return Option.none();
|
||||
return null;
|
||||
}
|
||||
current = parent;
|
||||
}
|
||||
@@ -66,25 +78,26 @@ export const make = Effect.fn("makeVcsProjectConfig")(function* () {
|
||||
configPath: string,
|
||||
) {
|
||||
const raw = yield* fileSystem.readFileString(configPath).pipe(
|
||||
Effect.map(Option.some),
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("failed to read VCS project config", {
|
||||
configPath,
|
||||
error,
|
||||
}).pipe(Effect.as(Option.none<string>())),
|
||||
}).pipe(Effect.as(null)),
|
||||
),
|
||||
);
|
||||
if (Option.isNone(raw)) return "auto" as const;
|
||||
if (raw === null) {
|
||||
return "auto" as const;
|
||||
}
|
||||
|
||||
const parsed = parseConfig(raw.value);
|
||||
if (Option.isNone(parsed)) {
|
||||
const parsed = parseConfig(raw);
|
||||
if (parsed === null) {
|
||||
yield* Effect.logWarning("invalid VCS project config", {
|
||||
configPath,
|
||||
});
|
||||
return "auto" as const;
|
||||
}
|
||||
|
||||
return configuredKind(parsed.value);
|
||||
return configuredKind(parsed);
|
||||
});
|
||||
|
||||
const resolveKind: VcsProjectConfigShape["resolveKind"] = Effect.fn(
|
||||
@@ -95,9 +108,11 @@ export const make = Effect.fn("makeVcsProjectConfig")(function* () {
|
||||
}
|
||||
|
||||
const configPath = yield* findConfigPath(input.cwd);
|
||||
if (Option.isNone(configPath)) return "auto";
|
||||
if (configPath === null) {
|
||||
return "auto";
|
||||
}
|
||||
|
||||
return yield* readConfiguredKind(configPath.value);
|
||||
return yield* readConfiguredKind(configPath);
|
||||
});
|
||||
|
||||
return VcsProjectConfig.of({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/web",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -727,9 +727,16 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
prompt,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
}),
|
||||
[composerModelOptions, prompt, selectedModel, selectedProvider, selectedProviderModels],
|
||||
[
|
||||
composerModelOptions,
|
||||
prompt,
|
||||
selectedInstanceId,
|
||||
selectedModel,
|
||||
selectedProvider,
|
||||
selectedProviderModels,
|
||||
],
|
||||
);
|
||||
|
||||
const selectedPromptEffort = composerProviderState.promptEffort;
|
||||
@@ -1018,21 +1025,23 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
const providerTraitsMenuContent = renderProviderTraitsMenuContent({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
const providerTraitsPicker = renderProviderTraitsPicker({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";
|
||||
import {
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type CSSProperties,
|
||||
type ReactNode,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { XIcon } from "lucide-react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
@@ -34,6 +41,19 @@ export interface ComposerBannerStackItem {
|
||||
readonly onDismiss?: () => void;
|
||||
}
|
||||
|
||||
function useDismissTimeoutCleanup(timeoutRef: RefObject<ReturnType<typeof setTimeout> | null>) {
|
||||
useEffect(() => {
|
||||
return () => clearDismissTimeout(timeoutRef);
|
||||
}, [timeoutRef]);
|
||||
}
|
||||
|
||||
function clearDismissTimeout(timeoutRef: RefObject<ReturnType<typeof setTimeout> | null>) {
|
||||
const timeout = timeoutRef.current;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
interface ComposerBannerStackProps {
|
||||
readonly className?: string;
|
||||
readonly items: ReadonlyArray<ComposerBannerStackItem>;
|
||||
@@ -42,20 +62,9 @@ interface ComposerBannerStackProps {
|
||||
export function ComposerBannerStack({ className, items }: ComposerBannerStackProps) {
|
||||
const [exitingItemId, setExitingItemId] = useState<string | null>(null);
|
||||
const dismissTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (exitingItemId && !items.some((item) => item.id === exitingItemId)) {
|
||||
setExitingItemId(null);
|
||||
}
|
||||
}, [exitingItemId, items]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (dismissTimeoutRef.current) {
|
||||
clearTimeout(dismissTimeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
const activeExitingItemId =
|
||||
exitingItemId && items.some((item) => item.id === exitingItemId) ? exitingItemId : null;
|
||||
useDismissTimeoutCleanup(dismissTimeoutRef);
|
||||
|
||||
if (items.length === 0) {
|
||||
return null;
|
||||
@@ -67,10 +76,10 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
}
|
||||
const stackedItems = items.slice(1);
|
||||
const hasStack = stackedItems.length > 0;
|
||||
const showCollapsedStackCap = hasStack && exitingItemId !== frontItem.id;
|
||||
const showCollapsedStackCap = hasStack && activeExitingItemId !== frontItem.id;
|
||||
|
||||
const requestDismiss = (item: ComposerBannerStackItem) => {
|
||||
if (!item.onDismiss || exitingItemId) {
|
||||
if (!item.onDismiss || activeExitingItemId) {
|
||||
return;
|
||||
}
|
||||
setExitingItemId(item.id);
|
||||
@@ -106,16 +115,16 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
<div
|
||||
className={cn(
|
||||
"relative z-10",
|
||||
exitingItemId === frontItem.id ? "pointer-events-none" : null,
|
||||
activeExitingItemId === frontItem.id ? "pointer-events-none" : null,
|
||||
)}
|
||||
style={{
|
||||
...exitTransitionStyle,
|
||||
...(exitingItemId === frontItem.id ? frontExitStyle : restingStyle),
|
||||
...(activeExitingItemId === frontItem.id ? frontExitStyle : restingStyle),
|
||||
}}
|
||||
>
|
||||
<ComposerBannerStackAlert
|
||||
item={frontItem}
|
||||
exiting={exitingItemId === frontItem.id}
|
||||
exiting={activeExitingItemId === frontItem.id}
|
||||
onDismissRequest={() => requestDismiss(frontItem)}
|
||||
/>
|
||||
</div>
|
||||
@@ -132,15 +141,15 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
{stackedItems.map((item) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className={cn(exitingItemId === item.id ? "pointer-events-none" : null)}
|
||||
className={cn(activeExitingItemId === item.id ? "pointer-events-none" : null)}
|
||||
style={{
|
||||
...exitTransitionStyle,
|
||||
...(exitingItemId === item.id ? stackedExitStyle : restingStyle),
|
||||
...(activeExitingItemId === item.id ? stackedExitStyle : restingStyle),
|
||||
}}
|
||||
>
|
||||
<ComposerBannerStackAlert
|
||||
item={item}
|
||||
exiting={exitingItemId === item.id}
|
||||
exiting={activeExitingItemId === item.id}
|
||||
onDismissRequest={() => requestDismiss(item)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionDescriptor,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
@@ -196,6 +197,7 @@ export function shouldRenderTraitsControls(input: {
|
||||
|
||||
export interface TraitsMenuContentProps {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
@@ -208,6 +210,7 @@ export interface TraitsMenuContentProps {
|
||||
|
||||
export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -228,11 +231,12 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
return;
|
||||
}
|
||||
setProviderModelOptions(threadTarget, provider, nextOptions, {
|
||||
...(instanceId ? { instanceId } : {}),
|
||||
model,
|
||||
persistSticky: true,
|
||||
});
|
||||
},
|
||||
[model, persistence, provider, setProviderModelOptions],
|
||||
[instanceId, model, persistence, provider, setProviderModelOptions],
|
||||
);
|
||||
const {
|
||||
descriptors,
|
||||
@@ -343,6 +347,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
|
||||
export const TraitsPicker = memo(function TraitsPicker({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -431,6 +436,7 @@ export const TraitsPicker = memo(function TraitsPicker({
|
||||
<MenuPopup align="start">
|
||||
<TraitsMenuContent
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
model={model}
|
||||
prompt={prompt}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
type ServerProviderModel,
|
||||
@@ -35,6 +36,7 @@ export type ComposerProviderState = {
|
||||
|
||||
type TraitsRenderInput = {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
@@ -76,8 +78,17 @@ function renderTraitsControl(
|
||||
Component: typeof TraitsMenuContent | typeof TraitsPicker,
|
||||
input: TraitsRenderInput,
|
||||
): ReactNode {
|
||||
const { provider, threadRef, draftId, model, models, modelOptions, prompt, onPromptChange } =
|
||||
input;
|
||||
const {
|
||||
provider,
|
||||
instanceId,
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
} = input;
|
||||
const hasTarget = threadRef !== undefined || draftId !== undefined;
|
||||
if (
|
||||
!hasTarget ||
|
||||
@@ -88,6 +99,7 @@ function renderTraitsControl(
|
||||
return (
|
||||
<Component
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
|
||||
@@ -21,6 +21,7 @@ import { createModelSelection } from "@t3tools/shared/model";
|
||||
// `stickyModelSelectionByProvider` maps are keyed by `ProviderInstanceId`
|
||||
// in production; these aliases keep the legacy-key migration tests concise.
|
||||
const CODEX_INSTANCE = ProviderInstanceId.make("codex");
|
||||
const CODEX_SECONDARY_INSTANCE = ProviderInstanceId.make("codex_secondary");
|
||||
const CLAUDE_AGENT_INSTANCE = ProviderInstanceId.make("claudeAgent");
|
||||
const CURSOR_INSTANCE = ProviderInstanceId.make("cursor");
|
||||
const CODEX_DRIVER = ProviderDriverKind.make("codex");
|
||||
@@ -1201,6 +1202,43 @@ describe("composerDraftStore modelSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("stores provider option changes on a selected custom instance", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProviderModelOptions(
|
||||
threadRef,
|
||||
CODEX_DRIVER,
|
||||
toSelections({ reasoningEffort: "low" }),
|
||||
{
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
model: "gpt-5-codex",
|
||||
persistSticky: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.activeProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_INSTANCE]).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("updates only the draft when sticky persistence is disabled", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ interface ComposerDraftStoreState {
|
||||
provider: ProviderDriverKind,
|
||||
nextProviderOptions: ReadonlyArray<ProviderOptionSelection> | null | undefined,
|
||||
options?: {
|
||||
instanceId?: ProviderInstanceId | null | undefined;
|
||||
model?: string | null | undefined;
|
||||
persistSticky?: boolean;
|
||||
},
|
||||
@@ -2456,7 +2457,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (normalizedProvider === null) {
|
||||
return;
|
||||
}
|
||||
const instanceKey = defaultInstanceIdForDriver(normalizedProvider);
|
||||
const instanceKey = options?.instanceId ?? defaultInstanceIdForDriver(normalizedProvider);
|
||||
const fallbackModel =
|
||||
normalizeModelSlug(options?.model, normalizedProvider) ??
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider] ??
|
||||
@@ -2501,7 +2502,9 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const { options: _, ...rest } = stickyBase;
|
||||
nextStickyMap[instanceKey] = rest as ModelSelection;
|
||||
}
|
||||
nextStickyActiveProvider = base.activeProvider ?? instanceKey;
|
||||
nextStickyActiveProvider = options.instanceId
|
||||
? instanceKey
|
||||
: (base.activeProvider ?? instanceKey);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -2514,6 +2517,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
...(options?.instanceId ? { activeProvider: instanceKey } : {}),
|
||||
modelSelectionByProvider: nextMap,
|
||||
};
|
||||
const nextDraftsByThreadKey = { ...state.draftsByThreadKey };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/contracts",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -242,9 +242,9 @@ describe("ssh tunnel scripts", () => {
|
||||
Effect.result(
|
||||
waitForHttpReady({
|
||||
baseUrl: "http://127.0.0.1:41773/",
|
||||
timeout: Duration.seconds(1),
|
||||
interval: Duration.millis(100),
|
||||
probeTimeout: Duration.millis(250),
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 100,
|
||||
probeTimeoutMs: 250,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
+23
-26
@@ -50,13 +50,11 @@ import {
|
||||
|
||||
export const DEFAULT_REMOTE_PORT = 3773;
|
||||
const REMOTE_PORT_SCAN_WINDOW = 200;
|
||||
const DEFAULT_HTTP_READY_TIMEOUT = Duration.seconds(30);
|
||||
const DEFAULT_HTTP_READY_INTERVAL = Duration.millis(100);
|
||||
const SSH_READY_TIMEOUT = Duration.seconds(20);
|
||||
const SSH_READY_PROBE_TIMEOUT = Duration.seconds(1);
|
||||
const TUNNEL_SHUTDOWN_TIMEOUT = Duration.seconds(2);
|
||||
const REMOTE_READY_TIMEOUT = Duration.seconds(15);
|
||||
const REMOTE_REUSE_READY_TIMEOUT = Duration.seconds(2);
|
||||
const SSH_READY_TIMEOUT_MS = 20_000;
|
||||
const SSH_READY_PROBE_TIMEOUT_MS = 1_000;
|
||||
const TUNNEL_SHUTDOWN_TIMEOUT_MS = 2_000;
|
||||
const REMOTE_READY_TIMEOUT_MS = 15_000;
|
||||
const REMOTE_REUSE_READY_TIMEOUT_MS = 2_000;
|
||||
|
||||
export interface RemoteT3RunnerOptions {
|
||||
readonly packageSpec?: string;
|
||||
@@ -688,9 +686,9 @@ export function buildRemoteLaunchScript(input?: RemoteT3RunnerOptions): string {
|
||||
T3_WAIT_READY_SCRIPT: stripTrailingNewlines(REMOTE_WAIT_READY_SCRIPT),
|
||||
T3_DEFAULT_REMOTE_PORT: String(DEFAULT_REMOTE_PORT),
|
||||
T3_REMOTE_PORT_SCAN_WINDOW: String(REMOTE_PORT_SCAN_WINDOW),
|
||||
T3_READY_TIMEOUT_MS: String(Duration.toMillis(REMOTE_READY_TIMEOUT)),
|
||||
T3_REUSE_READY_TIMEOUT_MS: String(Duration.toMillis(REMOTE_REUSE_READY_TIMEOUT)),
|
||||
T3_READY_PROBE_TIMEOUT_MS: String(Duration.toMillis(SSH_READY_PROBE_TIMEOUT)),
|
||||
T3_READY_TIMEOUT_MS: String(REMOTE_READY_TIMEOUT_MS),
|
||||
T3_REUSE_READY_TIMEOUT_MS: String(REMOTE_REUSE_READY_TIMEOUT_MS),
|
||||
T3_READY_PROBE_TIMEOUT_MS: String(SSH_READY_PROBE_TIMEOUT_MS),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -872,18 +870,17 @@ const readRemoteServerLogTail = Effect.fn("ssh/tunnel.readRemoteServerLogTail")(
|
||||
|
||||
export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(function* (input: {
|
||||
readonly baseUrl: string;
|
||||
readonly timeout?: Duration.Duration;
|
||||
readonly interval?: Duration.Duration;
|
||||
readonly probeTimeout?: Duration.Duration;
|
||||
readonly timeoutMs?: number;
|
||||
readonly intervalMs?: number;
|
||||
readonly probeTimeoutMs?: number;
|
||||
readonly path?: string;
|
||||
}): Effect.fn.Return<void, SshReadinessError, HttpClient.HttpClient> {
|
||||
const timeout = input.timeout ?? DEFAULT_HTTP_READY_TIMEOUT;
|
||||
const interval = input.interval ?? DEFAULT_HTTP_READY_INTERVAL;
|
||||
const probeTimeout = input.probeTimeout ?? SSH_READY_PROBE_TIMEOUT;
|
||||
const timeoutMs = Duration.toMillis(timeout);
|
||||
const intervalMs = Duration.toMillis(interval);
|
||||
const probeTimeoutMs = Duration.toMillis(probeTimeout);
|
||||
const retryPolicy = Schedule.spaced(interval);
|
||||
const timeoutMs = input.timeoutMs ?? 30_000;
|
||||
const intervalMs = input.intervalMs ?? 100;
|
||||
const probeTimeoutMs = input.probeTimeoutMs ?? SSH_READY_PROBE_TIMEOUT_MS;
|
||||
const retryPolicy = Schedule.spaced(Duration.millis(intervalMs)).pipe(
|
||||
Schedule.take(Math.max(0, Math.ceil(timeoutMs / intervalMs))),
|
||||
);
|
||||
const requestUrl = new URL(input.path ?? "/", input.baseUrl).toString();
|
||||
const client = yield* HttpClient.HttpClient;
|
||||
const lastProbeFailure = yield* Ref.make<unknown>(null);
|
||||
@@ -903,7 +900,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio
|
||||
Effect.gen(function* () {
|
||||
attempt += 1;
|
||||
const responseOption = yield* effect.pipe(
|
||||
Effect.timeoutOption(probeTimeout),
|
||||
Effect.timeoutOption(Duration.millis(probeTimeoutMs)),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new SshReadinessError({
|
||||
@@ -956,7 +953,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
Effect.timeoutOption(timeout),
|
||||
Effect.timeoutOption(Duration.millis(timeoutMs)),
|
||||
);
|
||||
|
||||
return yield* Option.match(result, {
|
||||
@@ -1239,7 +1236,7 @@ const startSshTunnel = Effect.fn("ssh/tunnel.startSshTunnel")(function* (input:
|
||||
yield* Effect.raceFirst(
|
||||
waitForHttpReady({
|
||||
baseUrl: input.httpBaseUrl,
|
||||
timeout: SSH_READY_TIMEOUT,
|
||||
timeoutMs: SSH_READY_TIMEOUT_MS,
|
||||
}),
|
||||
exitFailure,
|
||||
).pipe(
|
||||
@@ -1299,7 +1296,7 @@ const startSshTunnel = Effect.fn("ssh/tunnel.startSshTunnel")(function* (input:
|
||||
: child
|
||||
.kill({
|
||||
killSignal: "SIGTERM",
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT,
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT_MS,
|
||||
})
|
||||
.pipe(Effect.ignore),
|
||||
),
|
||||
@@ -1543,7 +1540,7 @@ const makeSshEnvironmentManager = Effect.fn("ssh/tunnel.SshEnvironmentManager.ma
|
||||
[
|
||||
tunnelEntry.process.kill({
|
||||
killSignal: "SIGTERM",
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT,
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT_MS,
|
||||
}),
|
||||
stopRemoteServer(
|
||||
tunnelEntry.target,
|
||||
@@ -1597,7 +1594,7 @@ const makeSshEnvironmentManager = Effect.fn("ssh/tunnel.SshEnvironmentManager.ma
|
||||
remotePort: entry.remotePort,
|
||||
});
|
||||
const readinessExit = yield* Effect.exit(
|
||||
waitForHttpReady({ baseUrl: entry.httpBaseUrl, timeout: REMOTE_REUSE_READY_TIMEOUT }),
|
||||
waitForHttpReady({ baseUrl: entry.httpBaseUrl, timeoutMs: 2_000 }),
|
||||
);
|
||||
if (Exit.isSuccess(readinessExit)) {
|
||||
yield* Effect.logDebug("ssh.environment.tunnel.reused", {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user