fix(cli): show active profile in TUI prompt

This commit is contained in:
burjorjee
2026-05-19 00:05:06 -07:00
committed by Teknium
parent 276e6cc52d
commit 8c3b065124
5 changed files with 44 additions and 1 deletions

View 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('')
})
})

View File

@@ -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
View 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
}

View File

@@ -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