Skip to content

Commit bae0732

Browse files
fix: Move LOGO constant inside logo() to fix namespace IIFE scoping
The UI namespace compiles to an IIFE in the bundled binary. Module-scope const declarations (like LOGO) are not accessible inside the IIFE, causing 'LOGO is not defined' at runtime when the logo() function is called (e.g. via codeq -s <session_id>). Fix by defining LOGO as a local constant inside the logo() function rather than injecting it at module scope outside the namespace.
1 parent fc970e8 commit bae0732

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

branding/apply.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,25 +240,21 @@ export const marks = "_^~"
240240
},
241241

242242
// CLI UI logo() function - update to render Q in purple
243+
// IMPORTANT: LOGO must be defined INSIDE the logo() function, not at module scope.
244+
// The UI namespace compiles to an IIFE in the bundled binary, and module-scope
245+
// const declarations are not accessible inside the IIFE.
243246
{
244247
pattern: "packages/opencode/src/cli/ui.ts",
245248
transform: (content, config) => {
246249
const logoStr = config.logo.cli.map((row) => ` [\`${row[0]}\`, \`${row[1]}\`],`).join("\n")
247250

248-
// Add LOGO constant and update logo() function to use it with purple Q
249-
let result = content.replace(
250-
/import \{ logo as glyphs \} from "\.\/logo"/,
251-
`import { logo as glyphs } from "./logo"
252-
253-
const LOGO = [
254-
${logoStr}
255-
]`
256-
)
257-
258-
// Replace the logo() function to use LOGO with purple Q rendering
259-
result = result.replace(
251+
// Replace the logo() function with LOGO defined as a local constant inside it
252+
const result = content.replace(
260253
/export function logo\(pad\?: string\) \{[\s\S]*?return result\.join\(""\)\.trimEnd\(\)\n \}/,
261254
`export function logo(pad?: string) {
255+
const LOGO = [
256+
${logoStr}
257+
]
262258
const result: string[] = []
263259
const reset = "\\x1b[0m"
264260
const left = {

0 commit comments

Comments
 (0)