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

@ -1375,6 +1375,15 @@ def _probe_config_health(cfg: dict) -> str:
return " ".join(warnings).strip()
def _current_profile_name() -> str:
try:
from hermes_cli.profiles import get_active_profile_name
return get_active_profile_name() or "default"
except Exception:
return "default"
def _session_info(agent) -> dict:
reasoning_config = getattr(agent, "reasoning_config", None)
reasoning_effort = ""
@ -1397,6 +1406,7 @@ def _session_info(agent) -> dict:
"update_behind": None,
"update_command": "",
"usage": _get_usage(agent),
"profile_name": _current_profile_name(),
}
try:
from hermes_cli import __version__, __release_date__
@ -2154,6 +2164,7 @@ def _(rid, params: dict) -> dict:
"skills": {},
"cwd": os.getenv("TERMINAL_CWD", os.getcwd()),
"lazy": True,
"profile_name": _current_profile_name(),
},
},
)

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