8000 feat(plugins): name a thread's agent and its mark on the plugin thread record by aorumbayev · Pull Request #154 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

feat(plugins): name a thread's agent and its mark on the plugin thread record - #154

Merged
aorumbayev merged 2 commits into
mainfrom
build-agent-name-for-plugin-threads
Nov 13, 2026
Merged

aorumbayev merged 2 commits into
mainfrom
build-agent-name-for-plugin-threads

Conversation

@aorumbayev
@aorumbayev aorumbayev commented Nov 13, 2026 •
Copy link
Copy Markdown
Member

What

The plugin Thread record (from threads.get, threads.list and threads.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), else null.
  • agentMark: that agent's bundled mark path, such as agents/claude.svg or agents/cursor.svg for cursor-agent, else null.

A sidebar draws the icon in one line: svg(thread.agentMark). When it is null, draw your own terminal icon. No name-to-path map is needed in a plugin.

The program line stays hidden. provider is 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 from crates/ui/src/kagan/picker/mark.rs to crates/domain/src/program.rs, beside KNOWN_PROGRAMS. A new agent_mark(line) runs split_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.
  • PluginThread fills agent and agentMark from that entry. threads.d.ts adds both, so kg plugin types prints them.

Can a plugin view draw agents/*.svg?

Yes. The proof is a chain of code facts, not a painting test:

  1. gpui-shell's svg(path) is a plain constructor (engine/quickjs/mod.rs:7652, text_constructor). Materialize passes the path unchanged to gpui::svg().path(path) (materialize.rs:1451).
  2. kagan's app reads every asset from one source, kg_ui::Assets (crates/kg/src/app.rs:148).
  3. That source loads every AGENT_MARKS path: every_mark_path_is_bundled in picker/mark.rs.

The limit: GPUI's TestAppContext hard-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, because svg, unlike image, 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-123 gives "claude" and "agents/claude.svg". bash and /opt/bin/my-tool --token sk-secret-456 give null. No part of either line appears in the serialized records.
  • The host test keeps provider absent and checks that < 8000 code class="notranslate">agent and agentMark are present and null for the fixture's claude-code.
  • Domain unit tests for 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

  • Decision 275 says why the fixed name and path are safe and the line is not. Under Rules out it adds "a name-to-path map in a plugin". Decision 271's reference to the table now points at kg-domain.
  • docs/plugin-api.md (Thread record) and docs/behaviour.md name both fields.
  • Size budget: product Rust went from main's 84088 to 84175 (+87), and the ceiling is set to that count.

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.
@aorumbayev aorumbayev changed the title feat(plugins): name a thread's agent on the plugin thread record feat(plugins): name a thread's agent and its mark on the plugin thread record Nov 13, 2026
@aorumbayev
aorumbayev merged commit b139803 into main Nov 13, 2026
21 checks passed
@aorumbayev
aorumbayev deleted the build-agent-name-for-plugin-threads branch November 13, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0