Skip to content

Fix shadow DOM text extraction for Monica.im and Cline#7

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-monica-imn-and-cline-issues
Draft

Fix shadow DOM text extraction for Monica.im and Cline#7
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-monica-imn-and-cline-issues

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Monica.im and Cline inject their UI via open shadow roots. element.innerText does not descend into shadow roots, so both document text extraction and selections within these containers were silently returning empty content.

Changes

content/extract-text.ts

  • collectShadowText(root) — new exported recursive helper that walks all shadow hosts in a subtree, collects innerText from each shadow root's direct HTMLElement children, and recurses into nested shadow roots.

  • extractDocumentText() — appends collectShadowText() output to the regular innerText result before the clean() pass.

  • extractSelection() — adds a getComposedRanges() fallback (Chrome 111+, within the extension's minimum of Chrome 127). When selection.toString() returns empty but a non-collapsed composed range exists, converts it to a live Range to recover the shadow-boundary selection text.

// Before: shadow content invisible
const text = clean(target.innerText || '');

// After: shadow roots traversed
const parts: string[] = [target.innerText || ''];
const shadowText = collectShadowText(target);
if (shadowText) parts.push(shadowText);

tests/panel/extract-text.test.mjs

Five new tests covering collectShadowText: no shadow roots, single shadow root, blank text ignored, nested shadow roots, multiple independent hosts.

Original prompt

Monica.im and Cline dont seem to work in the container.

[Chronological Review: The conversation began with the user requesting to initialize a process. The user then attached files and requested inspections and modifications related to the "selectpilot" repository. The user expressed a desire to remove certain elements, check the functionality of "package-lock.json," and sought recommendations. The user later requested to revert changes and to make "Cline" and "Monica.imn" work, indicating issues with these components in a container environment.]

[Intent Mapping:

  1. "/init" - User initiated a process.
  2. "Please do" - User requested action on the attached files.
  3. "Inspect it and report what it is" - User wanted an analysis of the attached files.
  4. "Remove it from this repo and check what package-lock.json does" - User aimed to delete a component and understand the package-lock.json file's purpose.
  5. "What do you recommend?" - User sought advice on the next steps.
  6. "revert" - User requested to undo previous changes.
  7. "Please make Cline and Monica.imn work" - User wanted to fix specific files.
  8. "Monica.im and Cline dont seem to work in the container" - User reported issues with functionality in a container.]

[Technical Inventory:

  • Repository: "selectpilot"
  • Files: "Cline", "Monica.imn", "package-lock.json"
  • Context: User is working within a container environment, indicating a need for compatibility and functionality of specific files.]

[Code Archaeology:

  • No specific code changes were documented in the conversation, but the user referenced files that need to be inspected and potentially modified.]

[Progress Assessment:

  • Completed Tasks: User has attached files and requested inspections.
  • Partially Complete Work: User is inquiring about the functionality of specific files and seeking recommendations for next steps.]

[Context Validation: All critical information for continuation is captured, including user requests for inspections, modifications, and troubleshooting of specific files.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to inspect files, remove components, check package-lock.json, and make specific files work.
  • Tool Results Summary: No specific tool results were provided, but the user is actively seeking to understand and resolve issues with the files mentioned.
  • Pre-Summary State: The agent was focused on addressing the issues with "Cline" and "Monica.imn" in the container environment when the token budget was exceeded.
  • Operation Context: The commands executed relate directly to the user's goal of ensuring that specific components function correctly within their project.]
1. Conversation Overview: - Primary Objectives: User requested to initialize a process, inspect files, remove components, check package-lock.json, seek recommendations, revert changes, and fix specific files. - Session Context: The conversation involved multiple requests for file inspections and modifications, indicating a focus on resolving issues within the "selectpilot" repository. - User Intent Evolution: The user transitioned from initialization and inspection to troubleshooting specific files that were not functioning as expected.
  1. Technical Foundation:
  • Repository: "selectpilot" - A project repository the user is working on.
  • Files: "Cline", "Monica.imn", "package-lock.json" - Specific files mentioned for inspection and modification.
  1. Codebase Status:
  • File Name: "package-lock.json"
  • Purpose: Manages dependencies for the project.
  • Current State: User requested to check its functionality.
  • Key Code Segments: Not specified in the conversation.
  • Dependencies: Related to the overall project dependencies.
  1. Problem Resolution:
  • Issues Encountered: User reported that "Cline" and "Monica.imn" do not work in the container.
  • Solutions Implemented: None documented yet; user is seeking recommendations.
  • Debugging Context: Ongoing troubleshooting of specific files in a container environment.
  • Lessons Learned: User is actively engaging in problem-solving for file functionality.
  1. Progress Tracking:
  • Completed Tasks: User has attached files and made several requests for inspections and modifications.
  • Partially Complete Work: User is still working on resolving issues with "Cline" and "Monica.imn."
  • Validated Outcomes: None confirmed yet.
  1. Active Work State:
  • Current Focus: User is addressing issues with "Cline" and "Monica.imn" in the container.
  • Recent Context: User reported functionality issues with specific files.
  • Working Code: No specific code snippets were discussed recently.
  • Immediate Context: User is troubleshooting the functionality of "Cline" and "Monica.imn."
  1. Recent Operations:
  • Last Agent Commands: User requested to inspect files, remove components, check package-lock.json, and make specific files work.
  • Tool Results Summary: No specific tool results were provided; user is actively seeking to understan...

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: kristoffersodersten <60147923+kristoffersodersten@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kristoffersodersten/selectpilot/sessions/2ce2ecbd-2e6c-4ca9-8eef-102a4402362a
Copilot AI changed the title [WIP] Fix issues with Monica.im and Cline in container Fix shadow DOM text extraction for Monica.im and Cline Mar 25, 2026
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