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
1 change: 1 addition & 0 deletions apps/server/src/environment/Layers/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const makeServerEnvironment = Effect.fn("makeServerEnvironment")(function
themes: true,
themeShowcase: true,
themeShowcaseTakeBack: true,
themeShowcaseUpdate: true,
themeVsCode: true,
eventTasks: true,
threadMove: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ System follows the computer's light or dark setting. In {place:appearance.system

An agent makes one with preview_theme (screenshots of the app wearing it, its readability checks and what its art costs) and offers it with show_theme: a row in the chat with Try it. Trying shows a bar at the top of the window, Keep or Undo, and it switches back by itself after 15 seconds (for a new version of a theme already kept from the same offer in that chat, the bar asks to Update that copy, with Keep both to add another); Esc, a reload or closing the window undo it too (while the /theme picker is open, a preview waits for its ✕ or Esc instead). The Settings gallery, the composer's /theme and an imported ${THEME_FILE_EXTENSION} file start the same trial. New theme, in /theme or in Settings, puts the start of a request in the message box ("Make me a Threadlines theme that feels like") with a few ideas to finish it (Settings opens a general chat for it); sending it asks the agent for one. In Settings, the options on a theme's picture rename it, duplicate it to change a copy, export a file to share, copy the request it was made from, or delete it; starters can be duplicated and exported. An exported file never says which thread made the theme and leaves the request out unless the user includes it; its author can add a credit (name, link, CC BY or CC0), which importing shows, and a theme that already has one keeps it.

The Showcase, beside Your themes in {place:settings.appearance}, lists themes people shared, reviewed before they're listed; clicking one starts the same trial. Share to Showcase…, in a theme's options, opens a public pull request to the Threadlines/themes repository from the GitHub account this computer is signed in to with gh, after showing what gets published. It's public the moment it's shared, under that account's name but without its email. It needs a CC BY or CC0 license, fonts that carry their own copyright and license, and no parts this version doesn't know; the theme's picture then says In review, In the Showcase, Taken back or Not added. Until it's added, Take back from Showcase…, in the same options, closes the pull request; GitHub keeps the closed one. Agents can't share or take back for the user.
The Showcase, beside Your themes in {place:settings.appearance}, lists themes people shared, reviewed before they're listed; clicking one starts the same trial. Share to Showcase…, in a theme's options, opens a public pull request to the Threadlines/themes repository from the GitHub account this computer is signed in to with gh, after showing what gets published. It's public the moment it's shared, under that account's name but without its email. It needs a CC BY or CC0 license, fonts that carry their own copyright and license, and no parts this version doesn't know; the theme's picture then says In review, In the Showcase, Taken back or Not added. For a theme you already shared, Update in Showcase… (or picking it in the share dialog) opens a pull request that updates its folder in place instead of adding a duplicate, leaving its metadata untouched. Until a share or update is merged, Take back from Showcase… (or Take back update…), in the same options, closes the pull request; GitHub keeps the closed one. Agents can't share or take back for the user.

Edit colors…, in a theme's options in {place:settings.appearance} (Light and Dark too) or "Edit theme colors…" in the command palette, opens a panel beside the app with the theme's own colors (background, text, quiet text, accent, text on accent, and the optional borders, status, code background and selected text). Every change shows across the app at once; Cancel or Esc puts back what was there. Each color says where it's hard to read, and Fix for me moves those colors a little until they read. Pick from the app, then a click anywhere, says which of those colors paints that spot. Save updates a theme in the library; any other is saved as a new theme.

Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/persistence/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import Migration0121 from "./Migrations/121_ProjectionThreadSecretRequests.ts";
import Migration0122 from "./Migrations/122_ProjectBriefs.ts";
import Migration0123 from "./Migrations/123_ProjectNotes.ts";
import Migration0124 from "./Migrations/124_ChildAccessAndStopColumns.ts";
import Migration0125 from "./Migrations/125_ThemeShowcaseUpdateBaseSha.ts";

/**
* Migration loader with all migrations defined inline.
Expand Down Expand Up @@ -280,6 +281,7 @@ export const migrationEntries = [
[122, "ProjectBriefs", Migration0122],
[123, "ProjectNotes", Migration0123],
[124, "ChildAccessAndStopColumns", Migration0124],
[125, "ThemeShowcaseUpdateBaseSha", Migration0125],
] as const;

/** Highest id in the full registry, so the "n of total" count is the real total. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Effect from "effect/Effect";
import * as SqlClient from "effect/sql/SqlClient";

/**
* When a Showcase share updates an already-listed theme (docs/design/custom-themes.md,
* "Showcase"): `update_base_sha` records the SHA-256 of the theme file on `main`
* when the update started (null for shares that add a new theme), and
* `published_file_sha` records the SHA-256 of the file this share writes.
*
* New columns only; no row is rewritten.
*/
export default Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
yield* sql`ALTER TABLE theme_showcase_submissions ADD COLUMN update_base_sha TEXT`;
yield* sql`ALTER TABLE theme_showcase_submissions ADD COLUMN published_file_sha TEXT`;
});
183 changes: 183 additions & 0 deletions apps/server/src/themes/ThemeShowcase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ const github = {
number: number;
url: string;
head: string;
title?: string;
body?: string;
state: string;
merged: boolean;
closedBy?: string;
Expand Down Expand Up @@ -227,6 +229,8 @@ const execute: GitHubCli.GitHubCliShape["execute"] = (input) => {
number,
url: `https://github.com/Threadlines/themes/pull/${number}`,
head: body.head,
title: body.title,
body: body.body,
state: "open",
merged: false,
};
Expand Down Expand Up @@ -539,6 +543,8 @@ it.layer(TestLayer)("ThemeShowcase", (it) => {
pullRequestUrl: null,
state: "inReview",
takenBack: null,
updateBaseSha: null,
publishedFileSha: null,
createdAt: "2026-11-09T12:00:00.000Z",
checkedAt: null,
});
Expand Down Expand Up @@ -756,4 +762,181 @@ it.layer(TestLayer)("ThemeShowcase", (it) => {
assert.isTrue(ready.problems.some((problem) => problem.includes("VS Code")));
}),
);

it.effect(
"updates an already-listed Showcase theme in place without touching meta.json, and tracks review until rebuilt",
() =>
Effect.gen(function* () {
const showcase = yield* ThemeShowcase;
const library = yield* ThemeLibrary;
const original: ThemeManifest = {
...harbor,
name: "Harbor Glow",
colors: { ...harbor.colors, accent: "#3b9eff" },
credits: { author: "Octo", license: "CC-BY-4.0" },
};
const saved = yield* library.save({ manifest: original });
const originalFile = new TextEncoder().encode(`${JSON.stringify(original, null, 2)}\n`);
const listedEntry = {
...(yield* Effect.promise(() => entryFor("harbor-glow", original, originalFile))),
sharedBy: "octocat",
featured: true,
};
const someoneElses = {
...(yield* Effect.promise(() =>
entryFor(
"other-glow",
{ ...original, name: "Other Glow", colors: { ...harbor.colors, accent: "#ff77aa" } },
originalFile,
),
)),
sharedBy: "sam",
};
setIndex([listedEntry, someoneElses]);

// Unchanged theme is refused without opening a pull request.
const writesBefore = github.writes.length;
const unchanged = yield* failure(
showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000001",
login: "octocat",
updateSlug: "harbor-glow",
}),
);
assert.match(unchanged.detail, /already up to date/);
assert.deepStrictEqual(github.writes.slice(writesBefore), []);

// Updating another account's folder is refused before writing anything.
const notOwner = yield* failure(
showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000002",
login: "octocat",
updateSlug: "other-glow",
}),
);
assert.match(notOwner.detail, /Only @sam can update Other Glow/);
assert.deepStrictEqual(github.writes.slice(writesBefore), []);

// Updating a missing folder is refused.
const missing = yield* failure(
showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000003",
login: "octocat",
updateSlug: "gone-theme",
}),
);
assert.match(missing.detail, /isn't in the Showcase anymore/);

// Edit the accent color and update in place.
const edited: ThemeManifest = {
...original,
colors: { ...original.colors, accent: "#3b76ff" },
};
yield* library.replace({ entryId: saved.entryId, manifest: edited });
const treesBefore = github.trees.length;
const updated = yield* showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000004",
login: "octocat",
updateSlug: "harbor-glow",
});
assert.strictEqual(updated.state, "inReview");
assert.strictEqual(updated.slug, "harbor-glow");
assert.strictEqual(updated.isUpdate, true);
const tree = github.trees[treesBefore]!;
assert.deepStrictEqual(
tree.tree.map((item) => item.path),
["themes/harbor-glow/theme.threadlines-theme", "themes/harbor-glow/thumbnail.png"],
);
const pull = github.pulls.find((candidate) => candidate.url === updated.pullRequestUrl)!;
assert.strictEqual(pull.title, "Update Harbor Glow");
assert.match(pull.body ?? "", /^Updates \*\*Harbor Glow\*\* in the Showcase/);
assert.deepInclude(recorded.at(-1), { event: "theme.showcase.shared" });
assert.strictEqual((recorded.at(-1)?.properties as { updated?: boolean }).updated, true);

// Merged, before the index rebuilds: still in review because the old file digest is still on main.
pull.state = "closed";
pull.merged = true;
clock += 10 * 60_000;
const beforeRebuild = (yield* showcase.submissions).submissions.find(
(row) => row.submissionId === "update000004",
)!;
assert.strictEqual(beforeRebuild.state, "inReview");

// Taking back an already-merged update says the update is already in the Showcase.
const alreadyMerged = yield* failure(showcase.takeBack({ submissionId: "update000004" }));
assert.match(alreadyMerged.detail, /update is already in the Showcase/);

// Once the index rebuilds with the new file digest, the update becomes listed.
const editedFile = github.blobs.find((b) => b.sha === tree.tree[0]!.sha)!.bytes;
const rebuiltEntry = {
...(yield* Effect.promise(() => entryFor("harbor-glow", edited, editedFile))),
sharedBy: "octocat",
featured: true,
};
setIndex([rebuiltEntry]);
clock += 40 * 60_000;
const afterRebuild = (yield* showcase.submissions).submissions.find(
(row) => row.submissionId === "update000004",
)!;
assert.strictEqual(afterRebuild.state, "listed");

// A rename-only update keeps the same content hash but changes the file digest:
// it must stay in review while open, even if another rename lands on main.
yield* library.rename({ entryId: saved.entryId, name: "Harbor Deep" });
const renamed = yield* showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000005",
login: "octocat",
updateSlug: "harbor-glow",
});
assert.strictEqual(renamed.state, "inReview");
assert.strictEqual(renamed.publishedHash, rebuiltEntry.hash);
const otherRenameFile = new TextEncoder().encode(
`${JSON.stringify({ ...edited, name: "Harbor Other" }, null, 2)}\n`,
);
const otherRenameEntry = {
...(yield* Effect.promise(() =>
entryFor("harbor-glow", { ...edited, name: "Harbor Other" }, otherRenameFile),
)),
sharedBy: "octocat",
featured: true,
};
setIndex([otherRenameEntry]);
clock += 40 * 60_000;
const renameStillOpen = (yield* showcase.submissions).submissions.find(
(row) => row.submissionId === "update000005",
)!;
assert.strictEqual(renameStillOpen.state, "inReview");

// A second rename while the first rename PR is open opens a new PR instead of returning the first.
yield* library.rename({ entryId: saved.entryId, name: "Harbor Midnight" });
const renamedAgain = yield* showcase.submit({
entryId: saved.entryId,
credits: null,
includePrompt: false,
submissionId: "update000006",
login: "octocat",
updateSlug: "harbor-glow",
});
assert.notStrictEqual(renamedAgain.pullRequestUrl, renamed.pullRequestUrl);

// Taking back the open rename update closes only the update PR.
const takenBack = yield* showcase.takeBack({ submissionId: "update000005" });
assert.deepInclude(takenBack, { state: "notAdded", takenBack: true, isUpdate: true });
}),
);
});
Loading
Loading