fix(cli): show active profile in TUI prompt
This commit is contained in:
19
ui-tui/src/__tests__/prompt.test.ts
Normal file
19
ui-tui/src/__tests__/prompt.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { composerPromptText } from '../lib/prompt.js'
|
||||
|
||||
describe('composerPromptText', () => {
|
||||
it('returns shell prompt for ! commands', () => {
|
||||
expect(composerPromptText('❯', 'coder', true)).toBe('$')
|
||||
})
|
||||
|
||||
it('prefixes named profiles onto the normal prompt', () => {
|
||||
expect(composerPromptText('❯', 'coder')).toBe('coder ❯')
|
||||
})
|
||||
|
||||
it('does not prefix default or custom profiles', () => {
|
||||
expect(composerPromptText('❯', 'default')).toBe('❯')
|
||||
expect(composerPromptText('❯', 'custom')).toBe('❯')
|
||||
expect(composerPromptText('❯')).toBe('❯')
|
||||
})
|
||||
})
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
stableComposerColumns
|
||||
} from '../lib/inputMetrics.js'
|
||||
import { PerfPane } from '../lib/perfPane.js'
|
||||
import { composerPromptText } from '../lib/prompt.js'
|
||||
|
||||
import { AgentsOverlay } from './agentsOverlay.js'
|
||||
import { GoodVibesHeart, StatusRule, StickyPromptTracker, TranscriptScrollbar } from './appChrome.js'
|
||||
@@ -170,7 +171,7 @@ const ComposerPane = memo(function ComposerPane({
|
||||
const ui = useStore($uiState)
|
||||
const isBlocked = useStore($isBlocked)
|
||||
const sh = (composer.inputBuf[0] ?? composer.input).startsWith('!')
|
||||
const promptText = sh ? '$' : ui.theme.brand.prompt
|
||||
const promptText = composerPromptText(ui.theme.brand.prompt, ui.info?.profile_name, sh)
|
||||
const promptWidth = composerPromptWidth(promptText)
|
||||
const promptBlank = ' '.repeat(promptWidth)
|
||||
const inputColumns = stableComposerColumns(composer.cols, promptWidth)
|
||||
|
||||
11
ui-tui/src/lib/prompt.ts
Normal file
11
ui-tui/src/lib/prompt.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function composerPromptText(prompt: string, profileName?: null | string, shellMode = false): string {
|
||||
if (shellMode) {
|
||||
return '$'
|
||||
}
|
||||
|
||||
if (profileName && !['default', 'custom'].includes(profileName)) {
|
||||
return `${profileName} ${prompt}`
|
||||
}
|
||||
|
||||
return prompt
|
||||
}
|
||||
@@ -148,6 +148,7 @@ export interface SessionInfo {
|
||||
lazy?: boolean
|
||||
mcp_servers?: McpServerStatus[]
|
||||
model: string
|
||||
profile_name?: string
|
||||
reasoning_effort?: string
|
||||
release_date?: string
|
||||
service_tier?: string
|
||||
|
||||
Reference in New Issue
Block a user