Skip to content

Commit 53523de

Browse files
[codecane] Fix CLI binary env var display by using clientEnvVars array
🤖 Generated with Codebuff Co-Authored-By: Codebuff <[email protected]>
1 parent 26835cc commit 53523de

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

cli/src/chat.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import {
5454
createMarkdownPalette,
5555
type ChatTheme,
5656
} from './utils/theme-system'
57+
import { env } from '@codebuff/common/env'
58+
import { clientEnvVars } from '@codebuff/common/env-schema'
5759
import { openFileAtPath } from './utils/open-file'
5860
import { formatValidationError } from './utils/validation-error-formatting'
5961
import { createValidationErrorBlocks } from './utils/create-validation-error-blocks'
@@ -270,22 +272,26 @@ export const App = ({
270272
})
271273
}
272274

273-
// Log all NEXT_PUBLIC_* environment variables
274-
const nextPublicEnvVars = Object.keys(process.env)
275-
.filter((key) => key.startsWith('NEXT_PUBLIC_'))
276-
.sort()
277-
278-
if (nextPublicEnvVars.length > 0) {
279-
const envVarsList = nextPublicEnvVars
280-
.map((key) => ` ${key}=${process.env[key]}`)
281-
.join('\n')
282-
283-
blocks.push({
284-
type: 'text',
285-
content: `\nEnvironment variables:\n${envVarsList}`,
286-
marginTop: 1,
275+
// Log all client environment variables (works with both dev and binary modes)
276+
// In binary mode, env vars are embedded via --define and accessible through the env object
277+
// In dev mode, they come from process.env via Infisical
278+
const envVarsList = clientEnvVars
279+
.map((key) => {
280+
const value = env[key]
281+
// Truncate long values for display
282+
const displayValue =
283+
typeof value === 'string' && value.length > 50
284+
? value.substring(0, 47) + '...'
285+
: value
286+
return ` ${key}=${displayValue}`
287287
})
288-
}
288+
.join('\n')
289+
290+
blocks.push({
291+
type: 'text',
292+
content: `\nEnvironment variables:\n${envVarsList}`,
293+
marginTop: 1,
294+
})
289295

290296
// Calculate path from home directory to repository root
291297
// agentsDir is typically in the root, so use its parent as the repository root

0 commit comments

Comments
 (0)