summaryrefslogtreecommitdiffhomepage
path: root/packages/app
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-08 19:28:58 -0500
committerGitHub <[email protected]>2026-03-08 19:28:58 -0500
commitb976f339e857be3fae20f179992aa82fbea24f08 (patch)
tree14655402aef6b5ba8e0c0c5c13797a3984319e6c /packages/app
parent7d7837e5b6eb0fc88d202936b726ab890f4add53 (diff)
downloadopencode-b976f339e857be3fae20f179992aa82fbea24f08.tar.gz
opencode-b976f339e857be3fae20f179992aa82fbea24f08.zip
feat(app): generate color palettes (#16232)
Diffstat (limited to 'packages/app')
-rw-r--r--packages/app/e2e/projects/projects-close.spec.ts24
-rw-r--r--packages/app/e2e/settings/settings.spec.ts15
-rw-r--r--packages/app/public/oc-theme-preload.js7
-rw-r--r--packages/app/src/components/terminal.tsx2
4 files changed, 32 insertions, 16 deletions
diff --git a/packages/app/e2e/projects/projects-close.spec.ts b/packages/app/e2e/projects/projects-close.spec.ts
index 76b1487e9..9454d683f 100644
--- a/packages/app/e2e/projects/projects-close.spec.ts
+++ b/packages/app/e2e/projects/projects-close.spec.ts
@@ -25,16 +25,26 @@ test("closing active project navigates to another open project", async ({ page,
await clickMenuItem(menu, /^Close$/i, { force: true })
await expect
- .poll(() => {
- const pathname = new URL(page.url()).pathname
- if (new RegExp(`^/${slug}/session(?:/[^/]+)?/?$`).test(pathname)) return "project"
- if (pathname === "/") return "home"
- return ""
- })
+ .poll(
+ () => {
+ const pathname = new URL(page.url()).pathname
+ if (new RegExp(`^/${slug}/session(?:/[^/]+)?/?$`).test(pathname)) return "project"
+ if (pathname === "/") return "home"
+ return ""
+ },
+ { timeout: 15_000 },
+ )
.toMatch(/^(project|home)$/)
await expect(page).not.toHaveURL(new RegExp(`/${otherSlug}/session(?:[/?#]|$)`))
- await expect(otherButton).toHaveCount(0)
+ await expect
+ .poll(
+ async () => {
+ return await page.locator(projectSwitchSelector(otherSlug)).count()
+ },
+ { timeout: 15_000 },
+ )
+ .toBe(0)
},
{ extra: [other] },
)
diff --git a/packages/app/e2e/settings/settings.spec.ts b/packages/app/e2e/settings/settings.spec.ts
index c2a8522eb..42fe0b06c 100644
--- a/packages/app/e2e/settings/settings.spec.ts
+++ b/packages/app/e2e/settings/settings.spec.ts
@@ -83,16 +83,23 @@ test("changing theme persists in localStorage", async ({ page, gotoSession }) =>
const select = dialog.locator(settingsThemeSelector)
await expect(select).toBeVisible()
+ const currentThemeId = await page.evaluate(() => {
+ return document.documentElement.getAttribute("data-theme")
+ })
+ const currentTheme = (await select.locator('[data-slot="select-select-trigger-value"]').textContent())?.trim() ?? ""
+
await select.locator('[data-slot="select-select-trigger"]').click()
const items = page.locator('[data-slot="select-select-item"]')
const count = await items.count()
expect(count).toBeGreaterThan(1)
- const firstTheme = await items.nth(1).locator('[data-slot="select-select-item-label"]').textContent()
- expect(firstTheme).toBeTruthy()
+ const nextTheme = (await items.locator('[data-slot="select-select-item-label"]').allTextContents())
+ .map((x) => x.trim())
+ .find((x) => x && x !== currentTheme)
+ expect(nextTheme).toBeTruthy()
- await items.nth(1).click()
+ await items.filter({ hasText: nextTheme! }).first().click()
await page.keyboard.press("Escape")
@@ -101,7 +108,7 @@ test("changing theme persists in localStorage", async ({ page, gotoSession }) =>
})
expect(storedThemeId).not.toBeNull()
- expect(storedThemeId).not.toBe("oc-1")
+ expect(storedThemeId).not.toBe(currentThemeId)
const dataTheme = await page.evaluate(() => {
return document.documentElement.getAttribute("data-theme")
diff --git a/packages/app/public/oc-theme-preload.js b/packages/app/public/oc-theme-preload.js
index f8c710496..5851f756e 100644
--- a/packages/app/public/oc-theme-preload.js
+++ b/packages/app/public/oc-theme-preload.js
@@ -1,6 +1,5 @@
;(function () {
- var themeId = localStorage.getItem("opencode-theme-id")
- if (!themeId) return
+ var themeId = localStorage.getItem("opencode-theme-id") || "oc-2"
var scheme = localStorage.getItem("opencode-color-scheme") || "system"
var isDark = scheme === "dark" || (scheme === "system" && matchMedia("(prefers-color-scheme: dark)").matches)
@@ -9,9 +8,9 @@
document.documentElement.dataset.theme = themeId
document.documentElement.dataset.colorScheme = mode
- if (themeId === "oc-1") return
+ if (themeId === "oc-2") return
- var css = localStorage.getItem("opencode-theme-css-" + themeId + "-" + mode)
+ var css = localStorage.getItem("opencode-theme-css-" + mode)
if (css) {
var style = document.createElement("style")
style.id = "oc-theme-preload"
diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx
index c27d6a977..9e5f12ee4 100644
--- a/packages/app/src/components/terminal.tsx
+++ b/packages/app/src/components/terminal.tsx
@@ -217,7 +217,7 @@ export const Terminal = (props: TerminalProps) => {
const currentTheme = theme.themes()[theme.themeId()]
if (!currentTheme) return fallback
const variant = mode === "dark" ? currentTheme.dark : currentTheme.light
- if (!variant?.seeds) return fallback
+ if (!variant?.seeds && !variant?.palette) return fallback
const resolved = resolveThemeVariant(variant, mode === "dark")
const text = resolved["text-stronger"] ?? fallback.foreground
const background = resolved["background-stronger"] ?? fallback.background