mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(cli): show active profile in TUI prompt
This commit is contained in:
parent
276e6cc52d
commit
8c3b065124
5 changed files with 44 additions and 1 deletions
|
|
@ -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(),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue