Skip to content

fix: honor the agent pin and the disabled setting when buttons open floating chats - #364

Merged
RAIT-09 merged 3 commits into
devfrom
fix/floating-button-agent-pin
Jul 15, 2026
Merged

fix: honor the agent pin and the disabled setting when buttons open floating chats#364
RAIT-09 merged 3 commits into
devfrom
fix/floating-button-agent-pin

Conversation

@RAIT-09

@RAIT-09 RAIT-09 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Description

Two pre-existing bugs in runPromptInChat's floating branch, both surfaced by the sidebar double-init review (#363):

The agent pin was silently dropped. Every view type carries an agent pin on its own channel — leaf views via Obsidian's view state (state.initialAgentId), embedded blocks via the fence's agent: field — but floating chats had no channel at all: openNewFloatingChat(initialExpanded, initialPosition) had no agent parameter, and the floating <ChatPanel> render passed no initialAgentId prop. A button with viewType: floating and a pinned agent opened the default agent instead, and the prompt (including autoSend) was delivered there. The pin now rides the existing creation-parameter chain (openNewFloatingChatcreateFloatingChatmount → component props) into ChatPanel's existing initialAgentId prop — the same receiving end the sidebar uses, so #363's directive-based init guard applies unchanged. The branch also stops reconstructing the target view id from a counter snapshot: openNewFloatingChat now returns the created container and the id is read from it, matching the editor-tab and right-pane branches.

Buttons bypassed the "Enable floating chat" setting. The setting (off by default) gates every re-entry point — the floating button and all four floating commands — but not creation via agent buttons or the in-window "new window" action. A window created while the feature is off becomes unreachable after a minimize (collapse is display: none; only a Session Manager click can recover it). openNewFloatingChat is now the single choke point: while disabled it shows a notice and returns null before burning an instance id, and the button branch feeds that into the existing if (!targetViewId) return, so no undeliverable prompt is queued.

A third commit aligns the two remaining unprefixed notices (both from the #341 button work) with the project-wide [Agent Client] prefix convention (37 of 40 notices already use it).

Related issue

None (tracked in the local backlog; found during the #363 multi-lens review).

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other

Checklist

  • npm run lint passes ("Use sentence case for UI text" warnings are acceptable for brand names)
  • npm run build passes
  • Tested in Obsidian
  • Existing functionality still works
  • Documentation updated if needed (no docs describe the broken behavior)

Testing environment

  • Agent: Claude Code + OpenCode. Verified: pinned button (pin ≠ default) with viewType: floating opens the pinned agent and delivers the prompt (with and without autoSend); unpinned button opens the default; commands, floating button, onload bootstrap instance, and the in-window "new window" action unchanged; with the setting disabled the button shows the notice, opens nothing, and queues nothing (re-enabling works normally); Session Manager shows the correct agent for pinned floating chats
  • OS: macOS

Screenshots

N/A

Summary by CodeRabbit

  • New Features

    • Floating chats can now open with a selected agent.
    • Floating chat creation respects the floating-chat setting and provides feedback when disabled.
    • Prompt actions target newly created floating chats more reliably.
  • Bug Fixes

    • Improved messaging when no embedded chat is available.
    • Standardized error notifications for failed agent actions.

RAIT-09 added 3 commits July 16, 2026 00:00
A window created while the feature is off becomes unreachable after a
minimize: the floating button and every floating command are gated by
the setting, leaving only the Session Manager to recover it.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bc0e569-d058-4814-9c94-5aedfc4f648b

📥 Commits

Reviewing files that changed from the base of the PR and between 514b130 and 1f61e1d.

📒 Files selected for processing (3)
  • src/plugin.ts
  • src/ui/AgentButtonBlock.tsx
  • src/ui/FloatingChatView.tsx

📝 Walkthrough

Walkthrough

initialAgentId now flows through floating chat creation into ChatPanel. Floating chat creation respects its enablement setting and returns its container, allowing prompt routing to use the actual view ID. Embedded-chat misses and agent-button errors show updated notices.

Changes

Floating chat routing

Layer / File(s) Summary
Initial agent propagation
src/ui/FloatingChatView.tsx
Floating chat mounting and creation forward initialAgentId through FloatingChatComponent to ChatPanel.
Prompt routing and creation controls
src/plugin.ts, src/ui/AgentButtonBlock.tsx
Floating chat creation is gated by enableFloatingChat and returns its container; floating prompt routing uses the returned view ID, while missing embedded chats and button errors show updated notices.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: maws7140

Poem

A rabbit hops through floating air,
Passing agent seeds everywhere.
The view ID points the prompt just right,
Notices glow when chats take flight.
“Thump-thump!” the bunny cheers tonight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving agent pins and respecting the disabled floating-chat setting.
Description check ✅ Passed The description matches the template and includes change details, related issue, type, checklist, testing environment, and screenshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/floating-button-agent-pin

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.

@RAIT-09 RAIT-09 self-assigned this Jul 15, 2026
@RAIT-09
RAIT-09 merged commit 818dc47 into dev Jul 15, 2026
2 checks passed
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