-
Notifications
You must be signed in to change notification settings - Fork 52
fix: widen TUI panel to prevent text truncation (#1191) #1193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3bdcfe7
fix: widen TUI panel to prevent text truncation in advanced settings
jesseturner21 b3c66b1
docs: add screenshot for PR
jesseturner21 fdbca07
chore: remove screenshot from repo
jesseturner21 2bf9331
fix: default Panel to fullWidth so it fills the terminal
jesseturner21 eb607ac
fix: revert wrap change, keep truncate for multi-select list
jesseturner21 44f3eb9
test: replace obsolete contentWidth test with fullWidth assertion
jesseturner21 cfffb1b
fix: remove content width cap, use full terminal width everywhere
jesseturner21 f3a6b9a
fix: replace manual width strings with Ink layout components
jesseturner21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,28 @@ | ||
| import { useStdout } from 'ink'; | ||
| import React, { type ReactNode, createContext, useContext } from 'react'; | ||
|
|
||
| /** Maximum content width cap */ | ||
| const MAX_CONTENT_WIDTH = 60; | ||
| const DEFAULT_WIDTH = 80; | ||
|
|
||
| interface LayoutContextValue { | ||
| /** Global content width: min(terminalWidth, MAX_CONTENT_WIDTH) */ | ||
| contentWidth: number; | ||
| } | ||
|
|
||
| const LayoutContext = createContext<LayoutContextValue>({ | ||
| contentWidth: MAX_CONTENT_WIDTH, | ||
| contentWidth: DEFAULT_WIDTH, | ||
| }); | ||
|
|
||
| // eslint-disable-next-line react-refresh/only-export-components | ||
| export function useLayout(): LayoutContextValue { | ||
| return useContext(LayoutContext); | ||
| } | ||
|
|
||
| /** | ||
| * Build the logo dynamically based on width. | ||
| * The logo has fixed text " >_ AgentCore" on left and version on right, | ||
| * with padding in between to fill the width. | ||
| */ | ||
| // eslint-disable-next-line react-refresh/only-export-components | ||
| export function buildLogo(width: number, version?: string): string { | ||
| const left = '│ >_ AgentCore'; | ||
| const right = version ? `v${version} │` : '│'; | ||
| // -2 for the border chars already in left/right | ||
| const innerWidth = width - 2; | ||
| const paddingNeeded = innerWidth - (left.length - 1) - (right.length - 1); | ||
| const padding = ' '.repeat(Math.max(0, paddingNeeded)); | ||
|
|
||
| const topBorder = '┌' + '─'.repeat(innerWidth) + '┐'; | ||
| const bottomBorder = '└' + '─'.repeat(innerWidth) + '┘'; | ||
| const middle = left + padding + right; | ||
|
|
||
| return `\n${topBorder}\n${middle}\n${bottomBorder}`; | ||
| } | ||
|
|
||
| interface LayoutProviderProps { | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| export function LayoutProvider({ children }: LayoutProviderProps) { | ||
| const { stdout } = useStdout(); | ||
| const terminalWidth = stdout?.columns ?? MAX_CONTENT_WIDTH; | ||
| const contentWidth = Math.min(terminalWidth, MAX_CONTENT_WIDTH); | ||
| const contentWidth = stdout?.columns ?? DEFAULT_WIDTH; | ||
|
|
||
| return <LayoutContext.Provider value={{ contentWidth }}>{children}</LayoutContext.Provider>; | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| export { LayoutProvider, useLayout, buildLogo } from './LayoutContext'; | ||
| export { LayoutProvider, useLayout } from './LayoutContext'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.