Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/server/src/project/ProjectFaviconResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ it.layer(layerTest)("ProjectFaviconResolverLive", (it) => {
}),
);

it.effect("skips a candidate under a file where its folder should be", () =>
Effect.gen(function* () {
const resolver = yield* ProjectFaviconResolver.ProjectFaviconResolver;
const path = yield* Path.Path;
const cwd = yield* makeTempDir;
// An empty `.idea` file: stat of `.idea/icon.svg` fails with ENOTDIR.
yield* writeTextFile(cwd, ".idea", "");
yield* writeTextFile(cwd, "AppIcon.icns", "icon");

expect(yield* resolver.resolvePath(cwd)).toBe(path.join(cwd, "AppIcon.icns"));
}),
);

it.effect("falls back at once when a cached favicon is deleted", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
11 changes: 10 additions & 1 deletion apps/server/src/project/ProjectFaviconResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as PlatformError from "effect/PlatformError";
import * as Predicate from "effect/Predicate";
import * as Schema from "effect/Schema";

import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
Expand Down Expand Up @@ -130,14 +131,22 @@ function extractIconHref(source: string): string | null {
return null;
}

// t4 fork: a file where the path needs a folder (an empty `.idea` file) means the path is absent too.
const isNotDirectory = (error: PlatformError.PlatformError) =>
error.reason._tag === "BadResource" &&
Predicate.hasProperty(error.reason.cause, "code") &&
error.reason.cause.code === "ENOTDIR";

export const optionOnNotFound = <A, R>(
effect: Effect.Effect<A, PlatformError.PlatformError, R>,
): Effect.Effect<Option.Option<A>, PlatformError.PlatformError, R> =>
effect.pipe(
Effect.asSome,
Effect.catchTags({
PlatformError: (error) =>
error.reason._tag === "NotFound" ? Effect.succeed(Option.none<A>()) : Effect.fail(error),
error.reason._tag === "NotFound" || isNotDirectory(error)
? Effect.succeed(Option.none<A>())
: Effect.fail(error),
}),
);

Expand Down
14 changes: 3 additions & 11 deletions apps/server/src/t4/frameAncestors.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// @effect-diagnostics processEnvInEffect:off -- t4 settings come from the client container's env.
/**
* Who may frame T3's web app (AI-131).
*
* Upstream v0.1.11 (#36395) answers every HTML page with `frame-ancestors
* 'none'` and `X-Frame-Options: DENY`, so no site can frame it. The t4
* dashboard opens T3 in a full-screen frame on a phone (`T3Frame.tsx`), and
* after the v0.1.11 rollout that frame was a white screen. `T4_FRAME_ANCESTORS`
* (compose) lists the origins allowed to frame T3 - the dashboard's - and every
* other site is still refused. X-Frame-Options has no allow-list, so it is left
* out when origins are named; browsers that read `frame-ancestors` ignore it.
*/
// t4 fork: upstream sends `frame-ancestors 'none'`, which blanks the t4 dashboard's phone frame.
// T4_FRAME_ANCESTORS names the origins allowed to frame T3; every other site is still refused.
// X-Frame-Options has no allow-list, so it is left out when origins are named.

const ORIGIN = /^https?:\/\/[a-z0-9.-]+(?::\d{1,5})?$/i;

Expand Down
Loading