|
1 | 1 | import { useStdout } from 'ink'; |
2 | 2 | import React, { type ReactNode, createContext, useContext } from 'react'; |
3 | 3 |
|
4 | | -/** Maximum content width cap */ |
5 | | -const MAX_CONTENT_WIDTH = 60; |
| 4 | +const DEFAULT_WIDTH = 80; |
6 | 5 |
|
7 | 6 | interface LayoutContextValue { |
8 | | - /** Global content width: min(terminalWidth, MAX_CONTENT_WIDTH) */ |
9 | 7 | contentWidth: number; |
10 | 8 | } |
11 | 9 |
|
12 | 10 | const LayoutContext = createContext<LayoutContextValue>({ |
13 | | - contentWidth: MAX_CONTENT_WIDTH, |
| 11 | + contentWidth: DEFAULT_WIDTH, |
14 | 12 | }); |
15 | 13 |
|
16 | 14 | // eslint-disable-next-line react-refresh/only-export-components |
17 | 15 | export function useLayout(): LayoutContextValue { |
18 | 16 | return useContext(LayoutContext); |
19 | 17 | } |
20 | 18 |
|
21 | | -/** |
22 | | - * Build the logo dynamically based on width. |
23 | | - * The logo has fixed text " >_ AgentCore" on left and version on right, |
24 | | - * with padding in between to fill the width. |
25 | | - */ |
26 | | -// eslint-disable-next-line react-refresh/only-export-components |
27 | | -export function buildLogo(width: number, version?: string): string { |
28 | | - const left = '│ >_ AgentCore'; |
29 | | - const right = version ? `v${version} │` : '│'; |
30 | | - // -2 for the border chars already in left/right |
31 | | - const innerWidth = width - 2; |
32 | | - const paddingNeeded = innerWidth - (left.length - 1) - (right.length - 1); |
33 | | - const padding = ' '.repeat(Math.max(0, paddingNeeded)); |
34 | | - |
35 | | - const topBorder = '┌' + '─'.repeat(innerWidth) + '┐'; |
36 | | - const bottomBorder = '└' + '─'.repeat(innerWidth) + '┘'; |
37 | | - const middle = left + padding + right; |
38 | | - |
39 | | - return `\n${topBorder}\n${middle}\n${bottomBorder}`; |
40 | | -} |
41 | | - |
42 | 19 | interface LayoutProviderProps { |
43 | 20 | children: ReactNode; |
44 | 21 | } |
45 | 22 |
|
46 | 23 | export function LayoutProvider({ children }: LayoutProviderProps) { |
47 | 24 | const { stdout } = useStdout(); |
48 | | - const terminalWidth = stdout?.columns ?? MAX_CONTENT_WIDTH; |
49 | | - const contentWidth = Math.min(terminalWidth, MAX_CONTENT_WIDTH); |
| 25 | + const contentWidth = stdout?.columns ?? DEFAULT_WIDTH; |
50 | 26 |
|
51 | 27 | return <LayoutContext.Provider value={{ contentWidth }}>{children}</LayoutContext.Provider>; |
52 | 28 | } |
0 commit comments