Unify Context-spawn entry point and surface agents globally #50

Manually merged
tvidal merged 1 commit from feat/050-unify-context-spawn-entry-point-and-surface-ag into master 2026-06-26 12:11:33 +02:00
Owner

Unify Context-spawn entry point and surface agents globally

Touches 6 files: ckeditor-lint/baseline.toml, ckeditor-lint/baseline_CHANGELOG.md, ckeditor/src/app_layout/ai_actions.rs, ckeditor/src/app_layout/dashboard_dispatch.rs, ckeditor/src/panels/zero_buffer.rs, ckeditor/src/session_command.rs.

Unify Context-spawn entry point and surface agents globally Touches 6 files: `ckeditor-lint/baseline.toml`, `ckeditor-lint/baseline_CHANGELOG.md`, `ckeditor/src/app_layout/ai_actions.rs`, `ckeditor/src/app_layout/dashboard_dispatch.rs`, `ckeditor/src/panels/zero_buffer.rs`, `ckeditor/src/session_command.rs`.
Author
Owner

It can borrow. The clone of key was left over from before the lifetime was threaded through ckeditor/src/app_layout/ai_actions.rs, and it is gone.

It can borrow. The clone of `key` was left over from before the lifetime was threaded through `ckeditor/src/app_layout/ai_actions.rs`, and it is gone.
Author
Owner

It runs per token. The buffer behind entries lives on the struct in ckeditor/src/panels/zero_buffer.rs now and is cleared rather than reallocated.

It runs per token. The buffer behind `entries` lives on the struct in `ckeditor/src/panels/zero_buffer.rs` now and is cleared rather than reallocated.
Author
Owner

Split. The decision in session_spawn_in_project_root is a pure function now, with its own tests in ckeditor/src/session_command.rs.

Split. The decision in `session_spawn_in_project_root` is a pure function now, with its own tests in `ckeditor/src/session_command.rs`.
tvidal approved these changes 2026-06-26 09:30:00 +02:00
tvidal left a comment

A clear improvement. The change in ckeditor/src/app_layout/ai_actions.rs is the part I would have argued for.

A clear improvement. The change in `ckeditor/src/app_layout/ai_actions.rs` is the part I would have argued for.
@ -82,0 +85,4 @@
for ctx in p.contexts.values() {
for (key, session) in &ctx.ai_sessions {
tabs.push(ai_panel::SessionTab {
key: key.clone(),
Owner

key is cloned on what looks like a hot path. Is the ownership forced here, or can this borrow?

`key` is cloned on what looks like a hot path. Is the ownership forced here, or can this borrow?
@ -368,0 +405,4 @@
out: &mut DashboardAction,
) {
show_section_header(ui, SECTION_AGENTS, theme);
let mut entries: Vec<(String, String, Color32)> = Vec::new();
Owner

entries allocates a fresh buffer per call. If this runs per frame or per token, can the buffer be reused?

`entries` allocates a fresh buffer per call. If this runs per frame or per token, can the buffer be reused?
@ -111,0 +95,4 @@
// worktree). Used only by `SpawnForBranch` when the caller is already
// on the target branch and no worktree exists for it. The AI panel
// `+ New` button does NOT come here — it always creates a worktree.
fn session_spawn_in_project_root(&mut self, ctx: &egui::Context) {
Owner

session_spawn_in_project_root reads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?

`session_spawn_in_project_root` reads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?
Both `+ New` buttons (AI panel and dashboard) now dispatch
`SessionCommand::Spawn`, which always forks a new worktree off the
project's `default_branch`. Removes the divergent
`session_spawn_at_root` / `session_spawn_new_worktree` helpers — the
AI panel previously forked off the active worktree's HEAD, so the
second click in a row landed on the wrong branch.

The AI panel session strip and a new dashboard `Agents` section both
read from every Context's `ai_sessions`, so running agents stay
visible regardless of which Context is active. Click an agent in
either surface to dispatch `SessionCommand::Switch`, which routes
through the existing per-Context focus + Context-switch logic.

Ratchet: `session_command::CkEditorApp` cyclomatic 25 → 24, RFC 26 → 24.
tvidal manually merged commit bb076cdd1e into master 2026-06-26 12:11:33 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
northgale/ckeditor!50
No description provided.