Skip to content

Commit 91d6560

Browse files
committed
feat: show small logo when terminal width is small
1 parent e5bb9c0 commit 91d6560

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

cli/src/chat.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { useSystemThemeDetector } from './hooks/use-system-theme-detector'
3737
import { useChatStore } from './state/chat-store'
3838
import { flushAnalytics } from './utils/analytics'
3939
import { getUserCredentials } from './utils/auth'
40-
import { LOGO } from './login/constants'
40+
import { LOGO, LOGO_SMALL } from './login/constants'
4141
import { createChatScrollAcceleration } from './utils/chat-scroll-accel'
4242
import { formatQueuedPreview } from './utils/helpers'
4343
import {
@@ -63,9 +63,7 @@ type ChatVariant = 'ai' | 'user' | 'agent' | 'error'
6363
const MAX_VIRTUALIZED_TOP_LEVEL = 60
6464
const VIRTUAL_OVERSCAN = 12
6565

66-
const LOGO_BLOCK = LOGO.split('\n')
67-
.filter((line) => line.length > 0)
68-
.join('\n')
66+
// LOGO_BLOCK moved to component to be reactive to terminal width changes
6967

7068
type AgentMessage = {
7169
agentName: string
@@ -160,6 +158,12 @@ export const App = ({
160158
const terminalWidth = resolvedTerminalWidth
161159
const separatorWidth = Math.max(1, Math.floor(terminalWidth) - 2)
162160

161+
// Determine which logo to use based on terminal width
162+
const logoToUse = terminalWidth >= 60 ? LOGO : LOGO_SMALL
163+
const logoBlock = logoToUse.split('\n')
164+
.filter((line) => line.length > 0)
165+
.join('\n')
166+
163167
const themeName = useSystemThemeDetector()
164168
const theme = chatThemes[themeName]
165169
const markdownPalette = useMemo(() => createMarkdownPalette(theme), [theme])
@@ -241,7 +245,7 @@ export const App = ({
241245
const blocks: ContentBlock[] = [
242246
{
243247
type: 'text',
244-
content: '\n\n' + LOGO_BLOCK,
248+
content: '\n\n' + logoBlock,
245249
},
246250
]
247251

cli/src/components/login-modal.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useLoginPolling } from '../hooks/use-login-polling'
1010
import { useSheenAnimation } from '../hooks/use-sheen-animation'
1111
import {
1212
LOGO,
13+
LOGO_SMALL,
1314
LINK_COLOR_DEFAULT,
1415
LINK_COLOR_CLICKED,
1516
COPY_SUCCESS_COLOR,
@@ -231,17 +232,6 @@ export const LoginModal = ({
231232
// Use pure black/white for logo
232233
const logoColor = isLightMode ? '#000000' : '#ffffff'
233234

234-
// Use custom hook for sheen animation
235-
const { applySheenToChar } = useSheenAnimation({
236-
logoColor,
237-
terminalWidth: renderer?.width,
238-
sheenPosition,
239-
setSheenPosition,
240-
})
241-
242-
// Parse logo lines
243-
const logoLines = parseLogoLines(LOGO)
244-
245235
// Calculate terminal width and height for responsive display
246236
const terminalWidth = renderer?.width || 80
247237
const terminalHeight = renderer?.height || 24
@@ -257,8 +247,20 @@ export const LoginModal = ({
257247
contentMaxWidth,
258248
maxUrlWidth,
259249
showFullLogo,
250+
showSmallLogo,
260251
} = calculateResponsiveLayout(terminalWidth, terminalHeight)
261252

253+
// Use custom hook for sheen animation
254+
const { applySheenToChar } = useSheenAnimation({
255+
logoColor,
256+
terminalWidth: renderer?.width,
257+
sheenPosition,
258+
setSheenPosition,
259+
})
260+
261+
// Parse logo lines based on which logo to show
262+
const logoLines = parseLogoLines(showSmallLogo ? LOGO_SMALL : LOGO)
263+
262264
// Slice logo lines to fit terminal width
263265
const logoDisplayLines = useMemo(
264266
() => logoLines.map((line) => line.slice(0, contentMaxWidth)),
@@ -340,7 +342,7 @@ export const LoginModal = ({
340342
}}
341343
>
342344
{/* Header - Logo or simple text based on terminal size */}
343-
{showFullLogo ? (
345+
{showFullLogo || showSmallLogo ? (
344346
<box
345347
key="codebuff-logo"
346348
style={{

cli/src/login/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ export const LOGO = `
1212
╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝
1313
`
1414

15+
export const LOGO_SMALL = `
16+
██████╗ ██████╗
17+
██╔════╝ ██╔══██╗
18+
██║ ██████╔╝
19+
██║ ██╔══██╗
20+
╚██████╗ ██████╔╝
21+
╚═════╝ ╚═════╝
22+
`
1523
// UI Color constants
1624
export const LINK_COLOR_DEFAULT = '#3b82f6'
1725
export const LINK_COLOR_CLICKED = '#1e40af'

cli/src/login/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function calculateResponsiveLayout(terminalWidth: number, terminalHeight:
125125

126126
// Show full logo on all terminal sizes as long as width allows
127127
const showFullLogo = contentMaxWidth >= 60
128+
const showSmallLogo = contentMaxWidth >= 20 && !showFullLogo
128129

129130
return {
130131
isVerySmall,
@@ -139,6 +140,7 @@ export function calculateResponsiveLayout(terminalWidth: number, terminalHeight:
139140
contentMaxWidth,
140141
maxUrlWidth,
141142
showFullLogo,
143+
showSmallLogo,
142144
}
143145
}
144146

0 commit comments

Comments
 (0)