Skip to content

fix(mcp): keep visible selections when hidden rows are selected - #2706

Open
Cynnamoroll wants to merge 2 commits into
e2e-inc:mainfrom
Cynnamoroll:fix/mcp-visible-selection-folding
Open

Cynnamoroll wants to merge 2 commits into
e2e-inc:mainfrom
Cynnamoroll:fix/mcp-visible-selection-folding

Conversation

@Cynnamoroll

@Cynnamoroll Cynnamoroll commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

In a long list, three collapsed selected rows can make MCP omit the only visible selected row. The app still reports that row as selected in the full tree.

What

Hidden rows no longer count toward the three-mark limit that protects a visible selection from folding. The final output cap and full screen.tree() output are unchanged. No API change.

How it works

Skip hidden subtrees when counting marks in packages/core/src/agent/screen-fold.ts:126.

Issue

Fixes #2704

Verified

Ran it locally: yes

The Electron reproduction left the control unchanged. The affected view still reported six hidden nodes.

main this PR
68 nodes, 18 shown. Message 15 missing. 68 nodes, 20 shown. Message 15 [selected] in both MCP responses.

Not run: rendered docs screenshots. The docs checks ran.

Commands and output

At 3535139, pnpm check and all 21 folding unit tests passed again. This follow-up only clarifies the existing output cap. Output below was captured at 03d52ca:

$ cd /tmp/e2e-selection-folding-repro && node probe.mjs
control
MCP observe: Current screen (..., 62 nodes, 20 shown):
  #2.1.39 row "Message 15" [selected]
hidden
MCP observe: Current screen (..., 68 nodes, 20 shown):
  #2.1.39 row "Message 15" [selected]
  … 6 hidden nodes (scrolled out or collapsed)

The probe exited 0 on both checkouts. See #2704 for setup commands. The main probe used c19837e; 1abeb95 adds only Japanese and Simplified Chinese translation updates.

$ npm exec --yes --package=pnpm@12.3.4 -- pnpm check
Found 0 warnings and 0 errors.
e2e plugin: checked 23 generated files
[exit 0]

$ npm exec --yes --package=pnpm@12.3.4 -- pnpm --filter e2e run test:unit
Test Files  268 passed (268)
     Tests  5596 passed | 2 skipped (5598)
[exit 0]

$ npm exec --yes --package=pnpm@12.3.4 -- pnpm --filter @e2e-dev/testbed test
Test Files  53 passed (53)
     Tests  654 passed | 3 skipped (657)
[exit 0]

An earlier workspace-wide pnpm test did not pass. It ran alongside a rebuild and reported missing build files, an offline MCP install failure, and a CLI cancellation assertion. The isolated package unit run above passed, including that cancellation test.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • Folded observations now apply the three-node limit to visible focused or selected nodes. Hidden nodes and their descendants no longer affect whether visible marked rows are retained.
  • Documentation
    • Updated the observation guides to clarify that the final output limits may still omit focused or selected rows from folded results.

Exclude hidden subtrees from the mark cap used by folded observations.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: MCP selection folding

Layer / File(s) Summary
Count visible marks during folding
packages/core/src/agent/screen-fold.ts, packages/e2e/tests/unit/agent-screen-fold.test.ts, docs/reference/mcp.mdx, plugins/e2e/skills/e2e/references/mcp.md, skills/e2e/references/mcp.md, .changeset/mcp-visible-selection-folding.md
Hidden nodes and their descendants no longer contribute to marking-state counts. Tests cover hidden selected nodes and cases with three or four visible selected rows. The observe references describe the visible-node limit and output caps. The changeset declares patch releases for @e2e-dev/core and e2e.

Possibly related PRs

  • e2e-inc/e2e#2621: Introduced the folding presenter and its selected- and focused-node retention limit, which this change updates for hidden nodes.

Suggested reviewers: kdy1

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 35351

Folded observations now keep a visible selected row even when collapsed rows hold selections, and the change is small and reversible. I found no merge-blocking risk.

Architecture risk: Low · up to 35351

Observation folding now bases its three-node mark-retention threshold on visible nodes, so hidden subtrees no longer cause marked visible nodes to be omitted.

Changed areas: docs, packages/core, packages/e2e, plugins, skills

Review details

Systems and components

  • observed — 1 changed file mapped to docs.
  • observed — packages/core (library) was modified; 1 changed file maps to changed impact.
  • observed — packages/e2e (library) was modified; 1 changed file maps to changed impact.
  • observed — 1 changed file mapped to plugins.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5155d64d-98ca-41b6-a8d2-2b30841f48ab
Commits

Reviewing files that changed from the base of the PR and between 03d52ca and 3535139.

Files selected for processing: 4

  • docs/reference/mcp.mdx
  • packages/core/src/agent/screen-fold.ts
  • plugins/e2e/skills/e2e/references/mcp.md
  • skills/e2e/references/mcp.md
Files skipped from review as they are similar to previous changes: 3

  • docs/reference/mcp.mdx
  • packages/core/src/agent/screen-fold.ts
  • skills/e2e/references/mcp.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread docs/reference/mcp.mdx Resolved
Comment thread packages/core/src/agent/screen-fold.ts Resolved
@github-actions github-actions Bot added the size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

The site runs each docs page as code, so a fork's pull request is previewed only after a maintainer reads it. To preview 3535139, comment /docs-preview 35351395ae887ed43d93f6e21827fbd92e340861.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@github-actions github-actions Bot added size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile and removed size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Dec 5, 2026

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 4 files (changes from recent commits).

View guided diff | Re-trigger cubic

@Cynnamoroll

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Dec 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: hidden selected rows can hide the visible selection in folded observations

1 participant