Repository navigation
feat(plugins): name a thread's agent and its mark on the plugin thread record - #154
Merged
Merged
Conversation
The plugin Thread record gains `agent`: the program's command name when it is a known agent with a bundled mark, else null. The program line stays hidden. One list, AGENT_MARKS in kg-domain, now serves the picker, the usage popup and the plugin host. Decision 273.
A sidebar draws a thread's agent in one line, svg(thread.agentMark), with no name-to-path map: agent_mark returns the AGENT_MARKS entry, so the name and the bundled path come from one lookup. Both fields are null for any other program, and the leak test covers both.
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.
What
The plugin
Threadrecord (fromthreads.get,threads.listandthreads.sidebar().threads[]) gains two read-only fields:agent: the program's command name when it is a known agent with a bundled mark (claude,codex,gemini,copilot,opencode,cursor-agent,kimi), elsenull.agentMark: that agent's bundled mark path, such asagents/claude.svgoragents/cursor.svgforcursor-agent, elsenull.A sidebar draws the icon in one line:
svg(thread.agentMark). When it isnull, draw your own terminal icon. No name-to-path map is needed in a plugin.The program line stays hidden.
provideris still absent, and both values are always fixed strings kagan ships, so no flag, path, model name or key from the line can reach a plugin.How
AGENT_MARKS(command → bundled mark path) moves fromcrates/ui/src/kagan/picker/mark.rstocrates/domain/src/program.rs, besideKNOWN_PROGRAMS. A newagent_mark(line)runssplit_program, keeps the file stem, and returns the matching table entry, so the name and the path come from one lookup. The picker, the usage popup and the plugin host all read this one list.PluginThreadfillsagentandagentMarkfrom that entry.threads.d.tsadds both, sokg plugin typesprints them.Can a plugin view draw
agents/*.svg?Yes. The proof is a chain of code facts, not a painting test:
svg(path)is a plain constructor (engine/quickjs/mod.rs:7652,text_constructor). Materialize passes the path unchanged togpui::svg().path(path)(materialize.rs:1451).kg_ui::Assets(crates/kg/src/app.rs:148).AGENT_MARKSpath:every_mark_path_is_bundledinpicker/mark.rs.The limit: GPUI's
TestAppContexthard-codes()as its asset source (test_context.rs:176), so no unit test can paint the real file. I tried a panel test pairing a good path with a../path. It cannot fail, becausesvg, unlikeimage, has no path check, so I did not keep it.Tests
a_thread_shows_its_agent_and_mark_and_nothing_else_of_its_program_line:/opt/bin/claude --model mx-secret-model --api-key sk-secret-123gives"claude"and"agents/claude.svg".bashand/opt/bin/my-tool --token sk-secret-456givenull. No part of either line appears in the serialized records.providerabsent and checks that < 8000 code class="notranslate">agent andagentMarkare present andnullfor the fixture'sclaude-code.agent_mark: flags, an absolute path, a quoted path with spaces (Cursor's entry), an unfinished quote, an unmarked program, and a known agent name used as an argument.Local Mac:
cargo fmt --check;cargo clippy --workspace --all-targets --locked -- -D warnings;cargo t -p kg-domain -p kg-ui -p kg-plugins --locked(1424 passed). The first commit's full workspace run: 2354 passed. The pre-push hook checks pass.Docs
docs/plugin-api.md(Thread record) anddocs/behaviour.mdname both fields.