feat(plugins): add on_status_bar_render hook for plugin-contributed status bar fragments#32299
Open
chpomob wants to merge 2 commits into
Open
feat(plugins): add on_status_bar_render hook for plugin-contributed status bar fragments#32299chpomob wants to merge 2 commits into
chpomob wants to merge 2 commits into
Conversation
…tatus bar fragments Plugins can now contribute extra text to the CLI status bar via the on_status_bar_render hook. The hook is invoked in both code paths of _build_status_bar_text() (medium and full width). Each registered callback receives a snapshot dict with session state (model, context usage, duration, background tasks, etc.) and may return a string to append, or None to contribute nothing. Closes NousResearch#8642
…ents() fragment paths The hook was only invoked in _build_status_bar_text() (string fallback), but the primary rendering path _get_status_bar_fragments() (which builds styled fragments for prompt_toolkit) never called it. This meant plugin contributions (quota status, etc.) were invisible in normal operation. Added hook invocation in both fragment sub-paths: - Medium width (< 76): ' · ' separator, appends styled fragment - Full width (>= 76): ' │ ' separator, inserts before duration Now 4/4 code paths invoke the hook: 2 string + 2 fragment.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an
on_status_bar_renderplugin hook that lets plugins contribute extra text fragments to the CLI status bar, without requiring patches tocli.py.Closes #8642.
Changes
hermes_cli/plugins.py"on_status_bar_render"toVALID_HOOKScli.pyon_status_bar_renderhook in both code paths of_build_status_bar_text():if width < 76): separator" · ",parts.append()" │ ",parts.insert(-1, extra)before durationEach callback receives a
snapshotdict and may return a string to append, orNoneto contribute nothing. The hook is wrapped in try/except so a misbehaving plugin cannot break the status bar.Snapshot dict
Plugins receive:
{ "model_short": str, "model_full": str, "context_percent": int, "context_tokens": int, "context_length": int, "duration": str, "session_id": str, "session_title": str, "active_background_tasks": int, "active_background_processes": int, "compressions": int, "prompt_elapsed": float or None, }Use cases
With this hook, plugins can cleanly add:
Backwards compatibility
No breaking changes. Plugins that don't register this hook see no difference. The hook is purely additive.
Tested
hermes update)