Skip to content

feat: add shareText#2104

Open
RohitKushvaha01 wants to merge 2 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:main
Open

feat: add shareText#2104
RohitKushvaha01 wants to merge 2 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:main

Conversation

@RohitKushvaha01
Copy link
Copy Markdown
Member

Closes #1936

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 15, 2026

Greptile Summary

This PR implements a "Share" feature that allows users to share selected text (or the current line when nothing is selected) from the editor via Android's native share sheet. The feature adds a shareText action to the System Cordova plugin, a new shareCommand in the CodeMirror command registry, and a share button in the editor's selection menu.

  • System.java: Adds a shareText case that uses runOnUiThread to launch an Intent.ACTION_SEND chooser; success callback fires after startActivity (before the user picks an app, which is the standard fire-and-forget pattern for share intents).
  • commandRegistry.js: Registers a shareCommand that collects all selected ranges (falling back to the current line when nothing is selected) and calls system.shareText.
  • selectionMenu.js: Adds a share icon to the context menu, shown only when text is selected and also visible in read-only mode (readOnly: true).

Confidence Score: 4/5

The core share flow is functionally correct, but two prior review findings remain unaddressed: a debug console.log passed as the success callback and an unrelated proot plugin bundled into package.json.

The shareText intent is dispatched on the UI thread and the JS bridge is wired correctly. The open items from earlier rounds — the console.log success callback that prints shared content to the console on every invocation, and the proot plugin added to package.json — are still present and lower confidence that the PR is ready to land as-is.

src/cm/commandRegistry.js (console.log callback) and package.json (unrelated proot dependency)

Important Files Changed

Filename Overview
src/plugins/system/android/com/foxdebug/system/System.java Adds shareText case with correct runOnUiThread dispatch; five imports introduced by this PR duplicate ones already present in the file.
src/cm/commandRegistry.js Adds shareCommand registered as readOnly-safe; passes console.log/console.error as success/error callbacks (see existing thread).
src/lib/selectionMenu.js Share item added with correct 'selected' mode and readOnly:true.
src/plugins/system/www/plugin.js Clean addition of shareText JS bridge function matching the Java implementation.
package.json Adds com.foxdebug.acode.rk.exec.proot, which is unrelated to the shareText feature (see existing thread).

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectionMenu
    participant CommandRegistry
    participant SystemPlugin_JS as system (window.system)
    participant SystemPlugin_Java as System.java (Cordova)
    participant Android as Android Share Sheet

    User->>SelectionMenu: Tap share icon (text selected)
    SelectionMenu->>CommandRegistry: exec("share")
    CommandRegistry->>CommandRegistry: shareCommand(view) collect selected ranges
    CommandRegistry->>SystemPlugin_JS: shareText(text, console.log, console.error)
    SystemPlugin_JS->>SystemPlugin_Java: cordova.exec("shareText", [text])
    SystemPlugin_Java->>SystemPlugin_Java: runOnUiThread
    SystemPlugin_Java->>Android: startActivity(Intent.ACTION_SEND chooser)
    SystemPlugin_Java-->>SystemPlugin_JS: callbackContext.success()
    Note over Android: User picks target app (async)
    Android-->>User: Text shared
Loading

Reviews (2): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread src/cm/commandRegistry.js Outdated
Comment thread src/cm/commandRegistry.js Outdated
Comment thread src/cm/commandRegistry.js
Comment thread src/plugins/system/android/com/foxdebug/system/System.java
Comment thread package.json
Comment thread src/lib/selectionMenu.js Outdated
@RohitKushvaha01
Copy link
Copy Markdown
Member Author

@greptileai

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.

Share selected text

1 participant