Skip to content

Commit dbd5108

Browse files
tim.huangclaude
andcommitted
fix(punkcode): anomalyco#4 强制稳定经典布局让左右栏回来
根因:upstream 实验性 V2 新布局(newLayoutDesigns)默认值 = VITE_OPENCODE_CHANNEL!=='prod',但 desktop renderer 构建从未注入 VITE_OPENCODE_CHANNEL → 恒 undefined → 默认恒 true → 桌面端跑进 V2 布局。 V2 在 layout.tsx 走「只渲染 main、不渲染左侧 project/session sidebar nav」 分支,且 session-header 把 search/fileTree/terminal/status 默认关掉,表现就是 「打开会话后左侧项目栏 + 右侧信息栏都没有」。 改动: - branding.ts 新增 FORCE_STABLE_LAYOUT=true(PunkcodeAI 产品决策:用稳定经典布局) - settings.tsx newLayoutDesignsDefault 在 FORCE_STABLE_LAYOUT 下钉死 false - electron.vite.config.ts renderer define 注入 VITE_OPENCODE_CHANNEL(对齐 channel, 顺带修 titlebar channel 角标) - 经典布局下新建会话走 NewSessionView,把它的小号 opencode Mark logo 一并脱敏成 PunkcodeAI 文字 logo(与 anomalyco#1 一致) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1bc1bca commit dbd5108

4 files changed

Lines changed: 37 additions & 3 deletions

File tree

packages/app/src/branding.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,25 @@ export const ISSUE_TRACKER_URL = "https://github.com/thkhxm/opencode/issues"
4343
* 模型下拉本身保留,让用户能切换模型。M6 接 `/cli/llm` 后下拉会显示真实模型列表。
4444
*/
4545
export const HIDE_PROVIDER_UI = true
46+
47+
/**
48+
* 是否强制使用 opencode 的「稳定经典布局」,关闭实验性 V2 新布局(newLayoutDesigns)。
49+
*
50+
* 背景(#4 打开会话后左右栏都不见了):
51+
* upstream opencode 有一套实验性「new layout designs」(V2),由 settings.general.
52+
* newLayoutDesigns 控制,默认值 = `VITE_OPENCODE_CHANNEL !== "prod"`。
53+
* 桌面端 renderer 构建(electron.vite.config.ts)并未注入 VITE_OPENCODE_CHANNEL,
54+
* 所以它恒为 undefined → 默认值恒为 true → 桌面端默认跑 V2 布局。
55+
*
56+
* 而 V2 布局在 layout.tsx 里走的是「只渲染 <main>、不渲染左侧 project/session
57+
* sidebar nav」的分支,且 session-header 把 search/fileTree/terminal/status 也
58+
* 默认关掉——表现就是「打开会话后左侧项目栏 + 右侧信息栏都没有」。V2 是上游未完成的
59+
* 实验设计,不适合作为 PunkcodeAI 产品默认。
60+
*
61+
* 因此 PunkcodeAI 桌面端强制用稳定经典布局:左侧项目/会话 sidebar + 右侧 review/
62+
* file-tree 面板都正常渲染。该开关把 newLayoutDesigns 的默认值钉死为 false。
63+
*
64+
* 注:新建会话空状态页因此走经典 NewSessionView(小号 Mark logo,已在 #1 一并脱敏成
65+
* PunkcodeAI 文字 logo),不再是 V2 的 opencode 大像素 wordmark 水印。
66+
*/
67+
export const FORCE_STABLE_LAYOUT = true

packages/app/src/components/session/session-new-view.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { useSync } from "@/context/sync"
44
import { useSDK } from "@/context/sdk"
55
import { useLanguage } from "@/context/language"
66
import { Icon } from "@opencode-ai/ui/icon"
7-
import { Mark } from "@opencode-ai/ui/logo"
87
import { getDirectory, getFilename } from "@opencode-ai/core/util/path"
8+
import { PRODUCT_NAME } from "@/branding"
99

1010
const MAIN_WORKTREE = "main"
1111
const CREATE_WORKTREE = "create"
@@ -53,7 +53,9 @@ export function NewSessionView(props: NewSessionViewProps) {
5353
<div class="flex-1 px-6 pb-30 flex items-center justify-center text-center">
5454
<div class="w-full max-w-200 flex flex-col items-center text-center gap-4">
5555
<div class="flex flex-col items-center gap-6">
56-
<Mark class="w-10" />
56+
{/* 品牌脱敏:原来是 opencode 像素 Mark logo,换成 PunkcodeAI 文字 logo
57+
(复用登录/注册页的 .punkcode-logo 霓虹流光样式)。 */}
58+
<div class="punkcode-logo font-mono text-2xl font-bold tracking-tight select-none">{PRODUCT_NAME}</div>
5759
<div class="text-20-medium text-text-strong">{language.t("session.new.title")}</div>
5860
</div>
5961
<div class="w-full flex flex-col gap-4 items-center">

packages/app/src/context/settings.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createStore, reconcile } from "solid-js/store"
22
import { createEffect, createMemo } from "solid-js"
33
import { createSimpleContext } from "@opencode-ai/ui/context"
44
import { persisted } from "@/utils/persist"
5+
import { FORCE_STABLE_LAYOUT } from "@/branding"
56

67
export interface NotificationSettings {
78
agent: boolean
@@ -55,7 +56,12 @@ export interface Settings {
5556
export const monoDefault = "System Mono"
5657
export const sansDefault = "System Sans"
5758
export const terminalDefault = "JetBrainsMono Nerd Font Mono"
58-
export const newLayoutDesignsDefault = import.meta.env.VITE_OPENCODE_CHANNEL !== "prod"
59+
// #4:PunkcodeAI 强制走稳定经典布局(FORCE_STABLE_LAYOUT),否则桌面端因为 renderer 没
60+
// 注入 VITE_OPENCODE_CHANNEL,newLayoutDesigns 恒默认 true,跑进未完成的 V2 布局导致
61+
// 「打开会话后左侧项目栏 + 右侧信息栏都没有」。详见 branding.ts FORCE_STABLE_LAYOUT 注释。
62+
export const newLayoutDesignsDefault = FORCE_STABLE_LAYOUT
63+
? false
64+
: import.meta.env.VITE_OPENCODE_CHANNEL !== "prod"
5965

6066
const monoFallback =
6167
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'

packages/desktop/electron.vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export default defineConfig({
9494
// renderer 端 branding.ts -> DEFAULT_API_BASE_URL 读这个;dev 指向本地 sub2api。
9595
"import.meta.env.PUNKCODE_API_BASE_URL": JSON.stringify(punkcodeApiBaseUrl),
9696
"import.meta.env.PUNKCODE_UPDATE_FEED_URL": JSON.stringify(punkcodeUpdateFeedUrl),
97+
// renderer 的 app 代码(settings.tsx newLayoutDesignsDefault、titlebar channel 角标)
98+
// 读 VITE_OPENCODE_CHANNEL。之前没注入恒为 undefined,导致 newLayoutDesignsDefault
99+
// 恒为 true(跑进 V2 实验布局,左右栏丢失,见 #4)。这里按解析出的 channel 注入对齐。
100+
"import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel),
97101
},
98102
plugins: [appPlugin, sentry],
99103
publicDir: "../../../app/public",

0 commit comments

Comments
 (0)