Skip to content

feat: improve React compatibility, text strategy fallbacks, and auto-connect#11

Open
gruckion wants to merge 1 commit intohypothesi:mainfrom
gruckion:feat/react-compat-and-text-strategy-improvements
Open

feat: improve React compatibility, text strategy fallbacks, and auto-connect#11
gruckion wants to merge 1 commit intohypothesi:mainfrom
gruckion:feat/react-compat-and-text-strategy-improvements

Conversation

@gruckion
Copy link
Copy Markdown

@gruckion gruckion commented Mar 7, 2026

Summary

  • React-compatible text input: The webview_interact type action now uses the native HTMLInputElement.prototype.value setter and dispatches InputEvent (instead of a generic Event) to correctly trigger React's synthetic event system. Previously, directly setting .value bypassed React's internal value tracker, causing controlled components to silently ignore typed input.
  • Enhanced "text" selector strategy: When no element is found by text content, the resolver now falls back to searching placeholder, aria-label, and title attributes. This makes the text strategy much more useful for finding form inputs and interactive elements that don't have visible text content.
  • Auto-connect on first tool call: Instead of throwing an error when no active driver_session exists, ensureReady() now automatically attempts to start a session. This removes a common friction point where every tool call required a manual driver_session start first, while still providing a clear error if auto-connect fails.

Why these changes?

  1. React is the most popular frontend framework used in Tauri apps. The previous text input implementation silently failed on React controlled inputs because React tracks value changes through its own internal mechanism. By using the native prototype setter and resetting React's _valueTracker, we ensure the input works across vanilla JS, React, Vue, and other frameworks.

  2. Form inputs rarely have visible text content. The text strategy was limited to matching textContent, which excluded <input> and <textarea> elements. Falling back to placeholder, aria-label, and title attributes makes it natural to say "find the element with text 'Search...'" and have it locate an input with that placeholder.

  3. Requiring manual driver_session start before every interaction was an unnecessary step when there's typically only one Tauri app running. Auto-connect eliminates this friction while still failing clearly if no app is available.

Test plan

  • Test text input on a React app with controlled <input> components
  • Test text input on a vanilla JS app to ensure no regression
  • Test text strategy finding elements by placeholder text
  • Test text strategy finding elements by aria-label
  • Test auto-connect when calling a tool without an active session
  • Test auto-connect error message when no Tauri app is running

🤖 Generated with Claude Code

…connect

- Fix text input for React apps by using native value setter and InputEvent
  instead of direct assignment, which React's synthetic event system ignores
- Enhance "text" selector strategy with fallback to placeholder, aria-label,
  and title attributes when no text content match is found
- Auto-connect to Tauri app when no active session exists instead of throwing
- Update package name and repository URL for fork

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
"repository": {
"type": "git",
"url": "https://github.com/hypothesi/mcp-server-tauri.git",
"url": "https://github.com/gruckion/mcp-server-tauri.git",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert this back to "hypothesi"

@@ -1,5 +1,5 @@
{
"name": "@hypothesi/tauri-mcp-server",
"name": "@gruckion/tauri-mcp-server",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert this back to "@hypothesi"

@yokuze
Copy link
Copy Markdown
Member

yokuze commented Mar 20, 2026

These are good improvements. If you could make the two tweaks in the comments I left, then rebase to fix the merge conflicts, I'll merge them in.

Thanks!

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