Skip to content

Promote stale agent targets when live titles prove they are sendable - #7043

Merged
AmethystLiang merged 3 commits into
mainfrom
live-agent-notes-targeting
Jul 2, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
live-agent-notes-targeting

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Allows promoting stale agent status-backed panes/tabs to eligible send targets when a live pane or tab title proves the agent is active and idle. Introduces detectAgentSendTitleStatus to parse titles and verify sendability, preventing sleep/resume or stale timeouts from incorrectly disabling active agent targets.

Screenshots

No visual change

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Reviewed the stale target promotion logic and PTY title detection. Checked that stale status-backed launch agent panes correctly resolve using the fresh live runtime titles, and verified that split-pane deduplication rules are preserved. Explicitly checked cross-platform compatibility: all title parsing logic utilizes standard RegExp and unicode prefix checks that operate identically on macOS, Linux, and Windows.

Security Audit

Conducted a security review. The changes only introduce pure title string regex matching and state derivation in the renderer. There are no IPC changes, no terminal command execution logic modifications, and no external inputs parsed unsafely.

Notes

No platform-specific risks or follow-up work required.


Open in Stage

- Extract centralized `detectAgentSendTitleStatus` helper to determine if an agent is ready or needs permission based on pane and tab titles.
- Prevent stale hook-backed status rows from disabling active targets when fresh live titles and PTYs prove they are sendable.
- Fallback to the tab's launch agent type when status-backed targets have unknown agent types.
- Add comprehensive test coverage for promoting stale pane targets and preserving permission blocks.
@ghost

ghost commented Jul 1, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Define agent title status detection logic
2 Enhance runtime pane title resolution
3 Promote stale running agent targets via titles
4 Update notes send targets with promotion logic
Open in Stage

Chapters generated by Stage for commit 0b1adb5 on Jul 2, 2026 5:41am UTC.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f23bac3e-ce85-49ec-bf98-b2eb689f57f4

📥 Commits

Reviewing files that changed from the base of the PR and between 0b1adb5 and 1c43adb.

📒 Files selected for processing (1)
  • src/renderer/src/lib/runtime-pane-title-leaf-id.ts

📝 Walkthrough

Walkthrough

Changes

This PR adds runtime pane-title resolution metadata, introduces title-based agent send-status detection, and wires that status into running-agent and notes-send target derivation. Running-agent targets now distinguish stale state from permission-required state using live title evidence. Notes-send targets now derive launch candidates per tab, resolve agent type from launch metadata when needed, and merge candidates with pane-aware deduplication. The related tests expand coverage for stale-status behavior, live-title promotion, and split-pane cases.

Related PRs: None identified.

Suggested labels: area/renderer, refactor, tests

Suggested reviewers: None specified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: promoting stale agent targets when live titles prove they are sendable.
Description check ✅ Passed The description includes all required sections and covers testing, review, security, screenshots, and notes.
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

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.

Introduce `resolveRuntimePaneTitleLeafResolution` to track whether a
tab has any reported runtime pane titles. Use this to ensure that a split
pane does not fall back to the overall tab title when another pane in the
same tab already has active title evidence, avoiding stale target status.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/renderer/src/lib/runtime-pane-title-leaf-id.ts (1)

98-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a short "why" comment on the fallback branch.

The !tabLayout?.root && hasOnePaneTitle && !hasMultiplePaneTitles condition (and the hasAnyPaneTitle: true suppression on Line 102) encodes the non-obvious rule that a single reported title only maps to the leaf when no layout root exists, and that any pane title present must suppress stale tab-title fallback elsewhere. The downstream callers (detectLaunchAgentPaneStatus, detectLiveAgentPaneStatus) both carry Why: comments, but this resolver — where the constraint actually lives — has none.

As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

💬 Suggested comment
+  // Why: with no layout root we can only attribute a title when exactly one
+  // pane reported one; otherwise flag hasAnyPaneTitle so callers suppress the
+  // stale tab-title fallback instead of borrowing another pane's title.
   if (!tabLayout?.root && hasOnePaneTitle && !hasMultiplePaneTitles) {
     return { title: firstTitle, hasAnyPaneTitle: true }
   }

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 332cb57f-082c-428a-b6b9-9c0922127d4a

📥 Commits

Reviewing files that changed from the base of the PR and between 03da8ea and 0b1adb5.

📒 Files selected for processing (7)
  • src/renderer/src/lib/agent-send-title-status.ts
  • src/renderer/src/lib/notes-send-agent-targets.test.ts
  • src/renderer/src/lib/notes-send-agent-targets.ts
  • src/renderer/src/lib/running-agent-targets.test.ts
  • src/renderer/src/lib/running-agent-targets.ts
  • src/renderer/src/lib/runtime-pane-title-leaf-id.test.ts
  • src/renderer/src/lib/runtime-pane-title-leaf-id.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/lib/agent-send-title-status.ts
  • src/renderer/src/lib/running-agent-targets.test.ts
  • src/renderer/src/lib/notes-send-agent-targets.test.ts
  • src/renderer/src/lib/running-agent-targets.ts
  • src/renderer/src/lib/notes-send-agent-targets.ts

When a tab layout does not have a root, we can only attribute a single
reported pane title. This ensures that any pane title still suppresses
the stale tab-title fallback.
@AmethystLiang
AmethystLiang merged commit 151c567 into main Jul 2, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#7043)

* Promote stale agent targets when live titles prove they are sendable

- Extract centralized `detectAgentSendTitleStatus` helper to determine if an agent is ready or needs permission based on pane and tab titles.
- Prevent stale hook-backed status rows from disabling active targets when fresh live titles and PTYs prove they are sendable.
- Fallback to the tab's launch agent type when status-backed targets have unknown agent types.
- Add comprehensive test coverage for promoting stale pane targets and preserving permission blocks.

* Prevent split panes from borrowing stale tab titles

Introduce `resolveRuntimePaneTitleLeafResolution` to track whether a
tab has any reported runtime pane titles. Use this to ensure that a split
pane does not fall back to the overall tab title when another pane in the
same tab already has active title evidence, avoiding stale target status.

* Resolve single pane title if tab layout lacks root

When a tab layout does not have a root, we can only attribute a single
reported pane title. This ensures that any pane title still suppresses
the stale tab-title fallback.
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