Skip to content

Extract native incoming-Intent parser from AndroidDocumentsPlugin#92

Merged
Renakoni merged 1 commit into
mainfrom
refactor/native-incoming-intent-parser
Jul 10, 2026
Merged

Extract native incoming-Intent parser from AndroidDocumentsPlugin#92
Renakoni merged 1 commit into
mainfrom
refactor/native-incoming-intent-parser

Conversation

@Renakoni

Copy link
Copy Markdown
Owner

Summary

Seventh PR of the semantic-decomposition series: moves ACTION_VIEW / ACTION_SEND parsing and classification out of AndroidDocumentsPlugin.java into a focused IncomingIntentParser that returns structured results. Behavior-preserving — event names, payload fields, error codes, messages, and log lines are unchanged.

Boundary

IncomingIntentParser.parse(Intent) returns one of six structured results: ignored, open-with document (URI), shared Markdown stream (URI), shared text (validated markdown + normalized MIME + raw title), or an open-with/share rejection carrying the stable code/message pair. The parser owns:

  • action routing incl. the SEND_MULTIPLE rejection,
  • the VIEW/SEND category allow-lists and content:// scheme checks,
  • EXTRA_STREAM/EXTRA_TEXT extraction with their malformed-extra handling (incl. the Tiramisu parcelable API split),
  • the shared-text MIME gate, byte-size validation via MarkdownCodec, and the EXTRA_TITLEEXTRA_SUBJECT→fallback title resolution (returned raw; the plugin still normalizes to a .md name at emission, keeping naming with TODO 8's territory),
  • the Markdown MIME/extension candidate rules (isMarkdownCandidate & co.) that the document read paths share,
  • the parse-stage rejection logs, which move with the reasoning verbatim.

Per the TODO, the parser owns no UI or persistence. The plugin keeps the duplicate-intent guard (instance state), ContentResolver document reads, URI-permission persistence, all JSObject/event building and Capacitor listener notification — its incoming path is now a dispatch switch over the parser result, with the three emitters (emitOpenWithDocument, emitSharedStream, emitSharedText) carrying the previously duplicated read/emit bodies unchanged.

Testing

  • New IncomingIntentParserTest (5 JUnit tests) locks the pure classification rules: Markdown extensions case-insensitively, exact Markdown MIME set, the plain-text-by-MIME vs extension-wins candidate rule, the any-text/*-or-empty shared-text gate, and MIME normalization. Native suite now 13/13 via gradlew testDebugUnitTest (CI-gated since Extract native Markdown codec from AndroidDocumentsPlugin #91).
  • Intent-level behavior smoke-verified on the emulator with real intents via adb: SEND text/plain accepted end-to-end (event emitted, display name SmokeTitle.md resolved from EXTRA_SUBJECT), VIEW file:// rejected through the full parser with the preserved unsupported scheme: file log, and SEND_MULTIPLE rejected. (A shell-issued VIEW content:// is blocked by the OS before reaching any app — adb limitation; the open-with happy path is a verbatim move whose preceding checks the rejection smoke exercised.)
  • compileDebugJavaWithJavac + assembleDebug green; Java-only diff, TS contract untouched.

Moves ACTION_VIEW/ACTION_SEND parsing and classification into an
IncomingIntentParser that returns structured results: open-with document
URI, shared Markdown stream URI, validated shared text with its raw
title, or a rejection with the stable code/message pair. The parser owns
the category allow-lists, scheme checks, EXTRA_STREAM/EXTRA_TEXT
extraction with their malformed-extra handling, the shared-text MIME
gate and byte validation, the SEND_MULTIPLE rejection, and the
Markdown MIME/extension candidate rules shared with the document read
paths. Parse-stage rejection logs move with the reasoning, preserving
the exact log lines.

The plugin keeps everything stateful and platform-facing: the
duplicate-intent guard, ContentResolver document reads, URI permission
persistence, JSObject/event emission (including the shared-text
document payload, whose display name is still normalized at emission),
and the Capacitor listeners. Event names, payload fields, error codes,
and messages are unchanged.

Adds IncomingIntentParserTest (5 JUnit tests) for the pure
classification rules; Intent-level behavior was smoke-verified on the
emulator with real SEND text (accepted, titled from EXTRA_SUBJECT),
file-scheme VIEW (rejected with the preserved scheme log), and
SEND_MULTIPLE (rejected) intents.
@Renakoni Renakoni merged commit bb0e874 into main Jul 10, 2026
5 checks passed
@Renakoni Renakoni deleted the refactor/native-incoming-intent-parser branch July 10, 2026 13:49
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