Skip to content

Commit cbfd64c

Browse files
committed
fix: align capture tests with current main
2 parents a63bfd8 + b6f7268 commit cbfd64c

22 files changed

Lines changed: 730 additions & 374 deletions

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
8686
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
8787
import { downloadAndShareAttachment } from "../../lib/attachmentDownload";
8888
import { hasWideMarkdownBlock } from "../../lib/wideMarkdownBlocks";
89+
import { faviconUrlForOrigin } from "@t3tools/shared/favicon";
8990
import {
9091
hasNativeSelectableMarkdownText,
9192
SelectableMarkdownText,
@@ -596,7 +597,8 @@ const MarkdownExternalLink = memo(function MarkdownExternalLink(props: {
596597
readonly href: string;
597598
readonly onPress: (href: string) => void;
598599
}) {
599-
const [failed, setFailed] = useState(() => failedMarkdownFaviconHosts.has(props.host));
600+
const [failedHost, setFailedHost] = useState<string | null>(null);
601+
const faviconUrl = faviconUrlForOrigin(`https://${props.host}`);
600602

601603
return (
602604
<NativeText
@@ -607,15 +609,17 @@ const MarkdownExternalLink = memo(function MarkdownExternalLink(props: {
607609
textDecorationLine: "none",
608610
}}
609611
>
610-
{!failed ? (
612+
{faviconUrl !== null &&
613+
failedHost !== props.host &&
614+
!failedMarkdownFaviconHosts.has(props.host) ? (
611615
<Image
612616
source={{
613-
uri: `https://www.google.com/s2/favicons?domain=${encodeURIComponent(props.host)}&sz=32`,
617+
uri: faviconUrl,
614618
}}
615619
style={[markdownLinkStyles.inlineIcon, markdownLinkStyles.favicon]}
616620
onError={() => {
617621
failedMarkdownFaviconHosts.add(props.host);
618-
setFailed(true);
622+
setFailedHost(props.host);
619623
}}
620624
/>
621625
) : (

‎apps/server/integration/providerService.integration.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ const makeIntegrationFixture = (options?: { readonly analytics?: Layer.Layer<Ana
100100
Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers),
101101
).pipe(Layer.provide(SqlitePersistenceMemory));
102102

103-
const layer = makeProviderServiceLive().pipe(Layer.provide(shared));
103+
const layer = makeProviderServiceLive().pipe(
104+
Layer.provide(NodeServices.layer),
105+
Layer.provide(shared),
106+
);
104107

105108
return {
106109
cwd,

‎apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ import { afterEach, describe, expect, it, vi } from "vite-plus/test";
3939

4040
import { deriveServerPaths, ServerConfig } from "../../config.ts";
4141
import { TextGenerationError } from "@t3tools/contracts";
42-
import { ProviderAdapterRequestError } from "../../provider/Errors.ts";
42+
import {
43+
ProviderAdapterRequestError,
44+
ProviderWorkspaceMissingError,
45+
type ProviderServiceError,
46+
} from "../../provider/Errors.ts";
4347
import { OrchestrationEventStoreLive } from "../../persistence/Layers/OrchestrationEventStore.ts";
4448
import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts";
4549
import { SqlitePersistenceMemory } from "../../persistence/Layers/Sqlite.ts";
@@ -181,7 +185,7 @@ describe("ProviderCommandReactor", () => {
181185
readonly stopSessionEffect?: () => Effect.Effect<void, ProviderAdapterRequestError>;
182186
readonly startSessionEffect?: (
183187
session: ProviderSession,
184-
) => Effect.Effect<ProviderSession, ProviderAdapterRequestError>;
188+
) => Effect.Effect<ProviderSession, ProviderServiceError>;
185189
readonly tryHandlePromptCommandEffect?: ProviderAuthService["Service"]["tryHandlePromptCommand"];
186190
}) {
187191
const now = "2026-01-01T00:00:00.000Z";
@@ -1217,6 +1221,58 @@ describe("ProviderCommandReactor", () => {
12171221
}),
12181222
);
12191223

1224+
effectIt.effect("shows the missing workspace message without a provider stack trace", () =>
1225+
Effect.gen(function* () {
1226+
const attempted = yield* Deferred.make<void>();
1227+
const missingCwd = "/missing/project/worktree";
1228+
const missingWorkspace = new ProviderWorkspaceMissingError({
1229+
threadId: ThreadId.make("thread-1"),
1230+
cwd: missingCwd,
1231+
});
1232+
const harness = yield* Effect.promise(() =>
1233+
createHarness({
1234+
startSessionEffect: () =>
1235+
Deferred.succeed(attempted, undefined).pipe(
1236+
Effect.andThen(Effect.fail(missingWorkspace)),
1237+
),
1238+
}),
1239+
);
1240+
1241+
yield* harness.engine.dispatch({
1242+
type: "thread.turn.start",
1243+
commandId: CommandId.make("cmd-turn-start-missing-workspace"),
1244+
threadId: ThreadId.make("thread-1"),
1245+
message: {
1246+
messageId: asMessageId("user-message-missing-workspace"),
1247+
role: "user",
1248+
text: "continue",
1249+
attachments: [],
1250+
},
1251+
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
1252+
runtimeMode: "approval-required",
1253+
createdAt: "2026-01-01T00:00:00.000Z",
1254+
});
1255+
yield* Deferred.await(attempted);
1256+
yield* Effect.promise(() => harness.drain());
1257+
1258+
const thread = (yield* Effect.promise(() => harness.readModel())).threads.find(
1259+
(entry) => entry.id === ThreadId.make("thread-1"),
1260+
);
1261+
expect(thread?.session).toMatchObject({
1262+
status: "error",
1263+
activeTurnId: null,
1264+
lastError: missingWorkspace.message,
1265+
});
1266+
const failure = thread?.activities.find(
1267+
(activity) => activity.kind === "provider.turn.start.failed",
1268+
);
1269+
expect(failure?.payload).toMatchObject({ detail: missingWorkspace.message });
1270+
expect(harness.runtimeSessions).toEqual([]);
1271+
expect(harness.sendTurn).not.toHaveBeenCalled();
1272+
expect(yield* Effect.promise(() => harness.readPendingTurnStarts())).toEqual([]);
1273+
}),
1274+
);
1275+
12201276
effectIt.effect("settles a failed provider startup and allows a clean retry", () =>
12211277
Effect.gen(function* () {
12221278
let failStartup = true;

‎apps/server/src/orchestration/Layers/ProviderCommandReactor.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { increment, orchestrationEventsProcessedTotal } from "../../observabilit
3434
import {
3535
ProviderAdapterRequestError,
3636
ProviderAdapterValidationError,
37+
ProviderWorkspaceMissingError,
3738
} from "../../provider/Errors.ts";
3839
import type { ProviderServiceError } from "../../provider/Errors.ts";
3940
import { TextGeneration } from "../../textGeneration/TextGeneration.ts";
@@ -56,6 +57,7 @@ import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts";
5657
import { GitWorkflowService } from "../../git/GitWorkflowService.ts";
5758
const isProviderAdapterRequestError = Schema.is(ProviderAdapterRequestError);
5859
const isProviderAdapterValidationError = Schema.is(ProviderAdapterValidationError);
60+
const isProviderWorkspaceMissingError = Schema.is(ProviderWorkspaceMissingError);
5961
const isProviderDriverKind = Schema.is(ProviderDriverKind);
6062

6163
type ProviderIntentEvent = Extract<
@@ -394,6 +396,9 @@ const make = Effect.gen(function* () {
394396
if (isProviderAdapterValidationError(failReason?.error)) {
395397
return failReason.error.issue;
396398
}
399+
if (isProviderWorkspaceMissingError(failReason?.error)) {
400+
return failReason.error.message;
401+
}
397402
return Cause.pretty(cause);
398403
};
399404

‎apps/server/src/provider/Errors.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ export class ProviderAdapterProcessError extends Schema.TaggedErrorClass<Provide
8585
}
8686
}
8787

88+
/**
89+
* ProviderWorkspaceMissingError - The session's working directory no longer
90+
* exists on disk, so no provider process can start in it.
91+
*/
92+
export class ProviderWorkspaceMissingError extends Schema.TaggedErrorClass<ProviderWorkspaceMissingError>()(
93+
"ProviderWorkspaceMissingError",
94+
{
95+
threadId: Schema.String,
96+
cwd: Schema.String,
97+
},
98+
) {
99+
override get message(): string {
100+
return `This thread's workspace folder no longer exists or is not a directory: ${this.cwd}. Restore the folder at this path before retrying.`;
101+
}
102+
}
103+
88104
/**
89105
* ProviderValidationError - Invalid provider API input.
90106
*/
@@ -197,6 +213,7 @@ export type ProviderAdapterError =
197213
export type ProviderServiceError =
198214
| ProviderValidationError
199215
| ProviderUnsupportedError
216+
| ProviderWorkspaceMissingError
200217
| ProviderInstanceNotFoundError
201218
| ProviderSessionNotFoundError
202219
| ProviderSessionDirectoryPersistenceError

‎apps/server/src/provider/Layers/ClaudeAdapter.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,10 @@ function toSessionPermissionUpdates(
191191
toolName: string,
192192
suggestions: ReadonlyArray<PermissionUpdate> | undefined,
193193
): Array<PermissionUpdate> {
194-
const sessionScoped = (suggestions ?? []).map(
195-
(suggestion): PermissionUpdate => ({
196-
...suggestion,
197-
destination: "session",
198-
}),
199-
);
194+
const sessionScoped = (suggestions ?? []).map((suggestion): PermissionUpdate => ({
195+
...suggestion,
196+
destination: "session",
197+
}));
200198
if (sessionScoped.length > 0) {
201199
return sessionScoped;
202200
}

‎apps/server/src/provider/Layers/CodexProvider.ts‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,19 +432,15 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
432432
// Usage is an enrichment: a failure or a slow answer degrades to "no
433433
// usage this probe" rather than costing the account and models.
434434
client.request("account/rateLimits/read", undefined).pipe(
435-
Effect.map(
436-
(response): CodexRateLimitsProbe => ({
437-
snapshot: response.rateLimits,
438-
resetCredits: response.rateLimitResetCredits,
439-
}),
440-
),
435+
Effect.map((response): CodexRateLimitsProbe => ({
436+
snapshot: response.rateLimits,
437+
resetCredits: response.rateLimitResetCredits,
438+
})),
441439
Effect.timeoutOption(Duration.millis(RATE_LIMITS_PROBE_TIMEOUT_MS)),
442440
Effect.map(
443-
Option.getOrElse(
444-
(): CodexRateLimitsProbe => ({
445-
failure: "Codex did not answer the usage request.",
446-
}),
447-
),
441+
Option.getOrElse((): CodexRateLimitsProbe => ({
442+
failure: "Codex did not answer the usage request.",
443+
})),
448444
),
449445
Effect.catch((error) =>
450446
Effect.logDebug("Codex rate-limit read failed.", { cause: error }).pipe(

0 commit comments

Comments
 (0)