Skip to content

fix(tui/swarm-rename): wire TUI rename handler to real swarm dispatch - #105

Closed
KooshaPari wants to merge 2 commits into
masterfrom
fix/a1-swarm-rename-wireup
Closed

KooshaPari wants to merge 2 commits into
masterfrom
fix/a1-swarm-rename-wireup

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

User description

Bug

TUI swarm panel rename (tui_state.rs:2326) showed "Rename sent" to the user but silently dropped the new_label. The UI existed; the dispatch was never wired.

Root cause

Audit lane A-1 (swarm rename UI lies) classified this as: (c) feature unfinished — UI shell present, dispatch stub never implemented. Original RenameSession request had no target_session_id field, and the TUI never populated it. The status message was hard-coded "Rename sent" regardless of whether the request was sent.

Fix

  • jcode-protocol: add target_session_id: Option<String> to Request::RenameSession
  • jcode-app-core (server/client_lifecycle): handle target_session_id in dispatch (follows the existing SetReasoningEffort pattern)
  • jcode-app-core: rename_session() now accepts optional target_session_id
  • jcode-tui: RenameConfirm populates pending_swarm_rename; remote key handler drains it and dispatches Request::RenameSession with the target session id

Tests

  • 2 new protocol roundtrip tests for target_session_id in crates/jcode-protocol/src/protocol_tests/core_events.rs

Validation

  • cargo check --workspace: passed (per commit trailer)
  • 11 files changed, +140/-26 LOC

tx-agent: jcode
tx-validated: cargo-check
tx-scope: crates/jcode-tui, crates/jcode-protocol, crates/jcode-app-core
tx-intent: TUI swarm rename now actually renames the target member session


CodeAnt-AI Description

Make swarm panel renames update the selected member

What Changed

  • Confirming a rename in the swarm panel now sends the new name to the selected swarm member instead of discarding it.
  • Renaming the current session continues to work as before; requests for a missing target session now return an error.

Impact

✅ Swarm member names update from the panel
✅ Clearer errors when a target session is missing

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

The TUI rename action in tui_state.rs:2326 logged "Rename sent" but
the new_label was dropped. Wire it to the real dispatch.

Changes:
- Protocol: add target_session_id to Request::RenameSession
- Server: handle target_session_id in client_lifecycle dispatch
  (follows SetReasoningEffort pattern)
- Backend: rename_session() now accepts optional target_session_id
- TUI: RenameConfirm populates pending_swarm_rename; remote key
  handler drains it and dispatches Request::RenameSession
- Tests: two new protocol roundtrip tests for target_session_id

Diagnosis: (c) feature was unfinished - UI existed but dispatch
was never wired.

tx-agent:     jcode
tx-validated: cargo-check
tx-scope:     crates/jcode-tui, crates/jcode-protocol, crates/jcode-app-core
tx-intent:    TUI swarm rename now actually renames the target member session
Copilot AI balanced review requested due to automatic review settings October 17, 2026 05:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 775d5559-c514-4fab-b47c-57433f822ddb
📥 Commits

Reviewing files that changed from the base of the PR and between bb22754 and 95de32f.

📒 Files selected for processing: 14
  • crates/jcode-app-core/src/server/client_actions.rs
  • crates/jcode-app-core/src/server/client_actions_tests.rs
  • crates/jcode-app-core/src/server/client_lifecycle.rs
  • crates/jcode-protocol/src/lib.rs
  • crates/jcode-protocol/src/protocol_tests/core_events.rs
  • crates/jcode-protocol/src/wire.rs
  • crates/jcode-tui/src/tui/app.rs
  • crates/jcode-tui/src/tui/app/input.rs
  • crates/jcode-tui/src/tui/app/remote/key_handling.rs
  • crates/jcode-tui/src/tui/app/tui_lifecycle.rs
  • crates/jcode-tui/src/tui/app/tui_state.rs
  • crates/jcode-tui/src/tui/backend.rs
  • crates/jcode-tui/src/tui/mod.rs
  • crates/jcode-tui/src/tui/ui_tests/mod.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai

codeant-ai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR e95ddb9 Oct 17, 2026 · 05:26 05:32

@codeant-ai

codeant-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Oct 17, 2026
Comment on lines +2021 to +2029
handle_rename_session(
id,
title,
&target_agent,
&target_session_id,
&swarm_members,
&client_event_tx,
)
.await;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: When the target agent is processing a turn, this await waits for its mutex inside the serial request loop, delaying every later request on this connection.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Performance

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/jcode-app-core/src/server/client_lifecycle.rs
**Line:** 2021:2029
**Comment:**
	*Performance: When the target agent is processing a turn, this await waits for its mutex inside the serial request loop, delaying every later request on this connection.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread crates/jcode-protocol/src/wire.rs Resolved
@codeant-ai

codeant-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown

CodeAnt PR Risk: Medium Risk

  • The PR needs attention before merging.
  • Rename confirmation reuses the selected index against a fresh member ordering, so a status update can apply the label to the wrong session.
  • Renaming a busy target can await its lock in the serial request loop, delaying later requests from the coordinator.
  • Older servers may ignore the target session field and rename the coordinator's own session instead of the selected member.

Assessed commit: e95ddb9d4ed7

@kilo-code-bot

kilo-code-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (15 files)
  • crates/jcode-app-core/src/server/client_actions.rs
  • crates/jcode-app-core/src/server/client_actions_tests.rs
  • crates/jcode-app-core/src/server/client_lifecycle.rs
  • crates/jcode-protocol/src/lib.rs
  • crates/jcode-protocol/src/protocol_tests/core_events.rs
  • crates/jcode-protocol/src/wire.rs
  • crates/jcode-tui/src/tui/app.rs
  • crates/jcode-tui/src/tui/app/input.rs
  • crates/jcode-tui/src/tui/app/remote/key_handling.rs
  • crates/jcode-tui/src/tui/app/tui_lifecycle.rs
  • crates/jcode-tui/src/tui/app/tui_state.rs
  • crates/jcode-tui/src/tui/backend.rs
  • crates/jcode-tui/src/tui/mod.rs
  • crates/jcode-tui/src/tui/ui_tests/mod.rs
Previous Review Summary

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review

This review did not finish. The model reached its output limit before it
could write the review — a reasoning model can spend the whole budget thinking.
Re-run the review, or lower the model's thinking effort, and it should get
further. Any inline comments below are from an earlier review.


Reviewed by free · Input: 153.6K · Output: 3.4K · Cached: 607.1K

@KooshaPari

Copy link
Copy Markdown
Owner Author

PR #105 codeant findings:

  • FIXED (tui_state.rs stale selection): capture the member session ID at rename start, consume it on confirmation, and clear it on cancellation. Live snapshots or selection changes cannot redirect the typed label.
  • FIXED (client_lifecycle.rs mutex wait): handle_rename_session now uses try_lock and returns an explicit busy/retry error if the target agent is locked, so the serial connection loop does not wait for a running agent. Added a regression test holding the agent lock while requesting rename.
  • FIXED (wire.rs older-server mismatch): use a distinct rename_swarm_session request with a required target ID; restore rename_session to its original self-only shape. Older servers reject the unknown verb instead of silently renaming the coordinator. Updated roundtrip tests and added a legacy-deserializer rejection / required-target regression.

Validation: cargo check -p jcode-app-core --no-default-features -j 1, cargo check -p jcode-protocol --no-default-features -j 1, and cargo check -p jcode-tui --no-default-features -j 1 all passed. Six protocol rename tests passed. The added busy-agent regression could not run because the existing Windows lib-test build fails at unchanged crates/jcode-app-core/src/tool/communicate/transport.rs:159: expect_err requires Stream: Debug (E0277). This validation blocker is recorded in the task RESULT; the unrelated source was preserved. Commit: 95de32f.

1 similar comment
@KooshaPari

Copy link
Copy Markdown
Owner Author

PR #105 codeant findings:

  • FIXED (tui_state.rs stale selection): capture the member session ID at rename start, consume it on confirmation, and clear it on cancellation. Live snapshots or selection changes cannot redirect the typed label.
  • FIXED (client_lifecycle.rs mutex wait): handle_rename_session now uses try_lock and returns an explicit busy/retry error if the target agent is locked, so the serial connection loop does not wait for a running agent. Added a regression test holding the agent lock while requesting rename.
  • FIXED (wire.rs older-server mismatch): use a distinct rename_swarm_session request with a required target ID; restore rename_session to its original self-only shape. Older servers reject the unknown verb instead of silently renaming the coordinator. Updated roundtrip tests and added a legacy-deserializer rejection / required-target regression.

Validation: cargo check -p jcode-app-core --no-default-features -j 1, cargo check -p jcode-protocol --no-default-features -j 1, and cargo check -p jcode-tui --no-default-features -j 1 all passed. Six protocol rename tests passed. The added busy-agent regression could not run because the existing Windows lib-test build fails at unchanged crates/jcode-app-core/src/tool/communicate/transport.rs:159: expect_err requires Stream: Debug (E0277). This validation blocker is recorded in the task RESULT; the unrelated source was preserved. Commit: 95de32f.

@KooshaPari

Copy link
Copy Markdown
Owner Author

Receipt: reviewed all three findings against current PR tip 95de32f.

  • FIXED (already present): swarm_rename_target captures the member session ID when editing begins; confirmation consumes that ID instead of resolving the current display index. Escape clears it.
  • FIXED (already present): handle_rename_session uses try_lock() and returns a busy/retry error immediately, avoiding a wait on the agent mutex in the serial request loop. The busy-agent regression test exercises this case. No larger refactor is needed.
  • FIXED (already present): RenameSwarmSession uses the distinct rename_swarm_session wire verb. Older servers reject that unknown verb instead of ignoring a target field on rename_session and renaming the coordinator. Ordinary self-renames keep the legacy verb.

Validation: inspected TUI capture/confirmation, backend serialization, protocol roundtrip tests, server dispatch, and the busy-agent regression test. Cargo validation was attempted but could not be completed in this environment; compilation/tests remain unverified (details in kcodeant-RESULT.md). No additional fix commit was needed or pushed.

KooshaPari added a commit that referenced this pull request Oct 17, 2026
* docs(audit): 2026-10-17 full-state audit mdset (10 lanes, 4 PRs)

10-agent subagent-driven audit of the KCode fork. 18 artifacts in this
mdset cover all 10 audit lanes plus the new artifacts from the in-flight
agents that completed during this cycle.

In this cycle we shipped:
- PR #99  fix(a2/auto-dream): make LLM-stub path honest
- PR #100 ci: add 4 load-bearing crates to CI workflow
- PR #101 docs(readme): correct provider count
- PR #105 fix(tui/swarm-rename): wire TUI rename handler (A-1 retry)

Investigated, not merged:
- PR #94 (fork builds never auto-update): 3 real issues filed in #104
- 9 STALE PRs: 7 closed, 4 commented, label 'needs-operator-decision' created
- 6 cherry-pick candidates identified (low-risk additive)
- 1 critical security patch (rustls/quinn-proto) requires manual Cargo.lock fix

Constraints honored:
- No destructive git ops
- No upstream PRs from KooshaPari/ (binding memo 2026-10-15)

tx-agent:     jcode
tx-validated: manual
tx-scope:     docs/audits/2026-10-17-full-state/
tx-intent:    persist 10-lane audit artifacts in the source repo

* docs(audit): verify CLI test target and correct fork divergence counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants