Skip to content

fix: project public agent focus to attached clients - #3764

Open
akbash-bot wants to merge 1 commit into
herdrdev:masterfrom
akbash-bot:akbash/3760-agent-focus-client-view
Open

fix: project public agent focus to attached clients#3764
akbash-bot wants to merge 1 commit into
herdrdev:masterfrom
akbash-bot:akbash/3760-agent-focus-client-view

Conversation

@akbash-bot

@akbash-bot akbash-bot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Issue

Running herdr agent focus reports success and changes server focus, but an attached client's viewport stays on its previous workspace.

Problem

Public focus handling did not classify agent.focus as client navigation after independent client views were introduced. The server changed the active pane without replacing each client's projected tab.

How did we fix it?

Herdr now projects a successful public agent focus to every attached shell client. It resolves the target after pending events are applied, then uses the existing public focus and geometry paths. Failed requests and client-originated navigation keep their existing behavior.

Verification

The new headless regression failed before with the client on w2 while the response focused w1. It now passes and verifies the response, client location, replacement snapshot, and rendered target surface. The matching disposable-session interaction now moves from SECOND_CURRENT_VIEW to FIRST_TARGET_VIEW. Five focused tests pass. CI passes on Linux, macOS, and Windows.

refs #3760

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 79f144d0-e79c-4c36-b499-80b8099ec529

📥 Commits

Reviewing files that changed from the base of the PR and between 9e01168 and ec338ce.

📒 Files selected for processing (2)
  • src/server/headless/client_views.rs
  • src/server/headless/tests/mod.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

AgentFocus requests now participate in geometry-change checks. The headless request handler extracts and proxies agent focus targets, resolves successful targets to TabSurfaceTarget, and marks focus successful when the target matches the new default shell target. An integration test verifies the API response, client location, shell snapshot, and rendered focused pane.

Merge Risk: ⚪ Minimal · up to ec338

Successful public agent-focus requests now update attached shell clients, with regression coverage for response, location, snapshot, and rendered surface. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: projecting public agent focus to attached clients.
Description check ✅ Passed The description directly explains the client viewport issue, the fix, and the regression test for public agent focus.
  • Fix all pre-merge checks with AI

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.


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.

@kangal-bot

Copy link
Copy Markdown
Collaborator

@coderabbitai review
@greptileai

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

@kangal-bot I will review pull request #3764.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes successful public agent.focus requests project the focused agent’s tab to attached shell clients.

  • Proxies the AgentFocus response so projection occurs only after successful request processing.
  • Resolves the focused agent after pending application events have been applied.
  • Reuses existing session-wide focus and controlled-tab geometry paths.
  • Adds a headless regression test covering a client whose view had diverged from server focus.

Confidence Score: 5/5

The PR appears safe to merge, with the new behavior following established session-wide focus and geometry paths.

No actionable failure was identified; unsuccessful requests remain non-projecting, successful AgentFocus requests resolve to the focused tab, and client-originated navigation retains its connection-local handling.

Important Files Changed

Filename Overview
src/server/headless/client_views.rs Adds success-gated public AgentFocus projection and integrates AgentFocus with existing shell geometry handling.
src/server/headless/tests/mod.rs Adds a headless regression test verifying response state, client projection replacement, and rendered target content.

Sequence Diagram

sequenceDiagram
    participant API as Public API client
    participant Server as Headless server
    participant App as Application runtime
    participant Shell as Attached shell clients

    API->>Server: agent.focus(target)
    Server->>App: Process request and pending events
    App-->>Server: AgentInfo success or error
    alt Successful focus
        Server->>Server: Resolve resulting tab
        Server->>Shell: Replace each shell projection
        Server->>Shell: Reapply controlled geometry
    else Failed focus
        Server-->>API: Forward error unchanged
    end
    Server-->>API: Forward response
Loading

Reviews (1): Last reviewed commit: "fix: project public agent focus to attac..." | Re-trigger Greptile

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.

2 participants