Skip to content

feat: bridge Studio profiles into web composers - #43

Merged
trvny merged 6 commits into
mainfrom
feat/studio-prompt-bridge
Sep 3, 2026
Merged

feat: bridge Studio profiles into web composers#43
trvny merged 6 commits into
mainfrom
feat/studio-prompt-bridge

Conversation

@trvny

@trvny trvny commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a provider-agnostic Studio Prompt Bridge for empty focused web composers
  • remember the last focused eligible textarea/contenteditable so the native toolbar can apply Studio after focus moves
  • reject generic inputs, non-empty editors, non-text attachments, off-provider pages, and provider/document navigation races
  • fall back to clipboard instead of overwriting or guessing provider DOM
  • expose Apply Studio in the web toolbar and existing Quick Prompt dialog

Generic text inputs intentionally remain clipboard-only unless a reliable provider composer marker is verified.

Validation: git diff --check passed. Final-head Android + KMP CI and CodeQL passed; debug APK artifact uploaded. No local Gradle run.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Bridges rendered Studio profiles into empty, focused provider web composers through guarded WebView JavaScript, preserves a clipboard fallback for unsafe or unavailable insertion, exposes the action in existing UI entry points, and adds focused Rhino tests for the bridge’s safety and behavior.

Sequence diagram for applying Studio to a web composer

sequenceDiagram
    actor User
    participant Toolbar as WebChatToolbar
    participant Screen as WebChatScreen
    participant WebView
    participant Bridge as StudioPromptBridge
    participant Composer as ProviderComposer
    participant Clipboard

    User->>Toolbar: onApplyStudio()
    Toolbar->>Screen: applyStudioPrompt()
    Screen->>Bridge: applyStudioPromptToFocusedEditor(webView, service, prompt)
    Bridge->>WebView: evaluateJavascript(studioPromptApplyScript)
    WebView->>Composer: Find focused or remembered editor
    alt Empty editor on owned HTTPS provider
        Composer-->>WebView: inserted
        WebView-->>Bridge: JavaScript result
        Bridge-->>Screen: INSERTED
        Screen-->>User: Show inserted snackbar
    else Unsafe, unavailable, non-empty, or rejected editor
        Composer-->>WebView: failure result
        WebView-->>Bridge: JavaScript result
        Bridge-->>Screen: Apply failure result
        Screen->>Clipboard: setPrimaryClip(studioPrompt)
        Screen-->>User: Show clipboard fallback snackbar
    end
Loading

State diagram for Studio prompt application outcomes

stateDiagram-v2
    [*] --> Ready
    Ready --> Inserted: applyStudioPromptToFocusedEditor()
    Ready --> ClipboardFallback: webView unavailable or off-provider
    Inserted --> [*]
    Ready --> ValidateEditor
    ValidateEditor --> ClipboardFallback: no editor
    ValidateEditor --> ClipboardFallback: editor not empty
    ValidateEditor --> DispatchInput
    DispatchInput --> Inserted: beforeinput accepted
    DispatchInput --> ClipboardFallback: beforeinput rejected or script failed
    ClipboardFallback --> [*]
Loading

File-Level Changes

Change Details Files
Add a provider-agnostic JavaScript bridge that inserts the rendered Studio profile into a safe, empty web composer.
  • Restrict injection to HTTPS pages on provider-owned hosts and recheck the runtime location to prevent navigation races.
  • Detect textareas, supported text inputs, and contenteditable elements while excluding password fields and non-empty editors.
  • Dispatch beforeinput/input/change events, honor canceled beforeinput events, and return conservative result tokens.
  • Track the last focused editable so toolbar focus changes do not lose the intended composer target.
  • Fall back to copying the profile when insertion is unavailable, unsafe, rejected, or unsuccessful.
app/src/main/java/com/twojstar/llmbench/web/StudioPromptBridge.kt
Expose Studio application from both the native web toolbar and the existing prompt helper dialog.
  • Wire the toolbar action to the active provider WebView and display result-specific snackbar feedback.
  • Replace the dialog’s primary copy action with Apply Studio to focused composer while retaining an explicit clipboard option.
  • Use the rendered Studio instructions with a default fallback profile text.
app/src/main/java/com/twojstar/llmbench/ui/screens/WebChatScreen.kt
Install composer focus tracking throughout WebView navigation and document the completed capability.
  • Install the target tracker whenever provider WebView pages change.
  • Mark empty-composer Studio application with clipboard fallback as complete in the project README.
app/src/main/java/com/twojstar/llmbench/ui/screens/WebChatScreen.kt
README.md
Add JavaScript-level coverage for provider restrictions, target selection, insertion behavior, and failure handling.
  • Test host/protocol filtering, navigation races, password exclusion, and protection of existing text.
  • Verify textarea and contenteditable insertion, event dispatch, remembered targets, and conservative callback parsing.
app/src/test/java/com/twojstar/llmbench/web/StudioPromptBridgeTest.kt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepsource-io

deepsource-io Bot commented Sep 3, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 9dff85a...ec20bce on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade  

Focus Area: Security
Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Kotlin Sep 3, 2026 11:39p.m. Review ↗
Secrets Sep 3, 2026 11:39p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

deepsource-io[bot]

This comment was marked as resolved.

@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 2a30e433-a664-4ea2-8225-9b5806fb13cf

📥 Commits

Reviewing files that changed from the base of the PR and between 52de942 and ec20bce.

📒 Files selected for processing (2)
  • app/src/main/java/com/twojstar/llmbench/web/StudioPromptBridge.kt
  • app/src/test/java/com/twojstar/llmbench/web/StudioPromptBridgeTest.kt

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

新增 Studio 指令应用流程。WebView 仅在受支持服务的 HTTPS 页面中跟踪最近聚焦的可编辑元素,并向空编辑器注入指令。流程排除搜索框、邮箱框、隐藏、禁用和只读元素。注入失败、页面不匹配或编辑器不可用时复制指令。WebChat 界面新增应用入口、结果提示和测试覆盖。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to ec20b

This change safely applies Studio content only to eligible empty web composers and falls back to the clipboard when insertion is unavailable. No merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant WebChatScreen
  participant StudioPromptBridge
  participant WebView
  participant FocusedEditor
  WebChatScreen->>StudioPromptBridge: 应用 Studio 指令
  StudioPromptBridge->>WebView: 执行注入脚本
  WebView->>FocusedEditor: 写入空编辑器并派发事件
  FocusedEditor-->>WebView: 返回注入状态
  WebView-->>StudioPromptBridge: 返回结果令牌
  StudioPromptBridge-->>WebChatScreen: 显示结果或复制指令
Loading

Poem

Studio 指令进入聚焦输入框
空白编辑器接收新内容
不合资格的目标被拒绝
页面不符时复制指令
WebView 传递结果状态
测试覆盖每条路径

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 40.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 标题准确概括了主要变更:将 Studio 配置桥接到 Web composer。措辞简洁且与变更内容一致。
Description check ✅ Passed 描述与变更内容直接相关,并说明了 Studio Prompt Bridge、编辑器限制、剪贴板回退、界面入口和验证结果。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/studio-prompt-bridge

Comment @coderabbitai help to get the list of available commands.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Sep 3, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 2 potential issues.

Devin Review

Comment thread app/src/main/java/com/twojstar/llmbench/web/StudioPromptBridge.kt Outdated
Comment thread app/src/main/java/com/twojstar/llmbench/ui/screens/WebChatScreen.kt
coderabbitai[bot]

This comment was marked as resolved.

deepsource-io[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@sourcery-ai
sourcery-ai Bot dismissed their stale review September 3, 2026 23:07

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@kanarek-companion

kanarek-companion Bot commented Sep 3, 2026

Copy link
Copy Markdown

🐤 Kanarek · 🟣 merged

main

It landed in main. Kanarek closes the notebook.

Documentation, App · 4 files

coderabbitai[bot]

This comment was marked as resolved.

deepsource-io[bot]

This comment was marked as resolved.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/main/java/com/twojstar/llmbench/web/StudioPromptBridge.kt (1)

47-76: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

恢复受控的文本 composer 支持。

当支持的服务使用 input type="text" 作为 composer 时,llmbenchFindEditable 会在 tag === 'input' 分支无条件返回 nullstudioPromptApplyScript 因此返回 "no-editor",界面会复制内容,而不会插入内容。

仅接受带明确 composer 标记的输入框,或使用静态服务注册表。保留对密码、搜索和账户输入框的拒绝逻辑,并添加允许的文本 composer 回归测试。


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d6a87858-392d-49e0-8ad3-87379d84d028

📥 Commits

Reviewing files that changed from the base of the PR and between 72e31a1 and 1573173.

📒 Files selected for processing (2)
  • app/src/main/java/com/twojstar/llmbench/web/StudioPromptBridge.kt
  • app/src/test/java/com/twojstar/llmbench/web/StudioPromptBridgeTest.kt

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.

@trvny
trvny merged commit 079e818 into main Sep 3, 2026
8 of 10 checks passed
@trvny
trvny deleted the feat/studio-prompt-bridge branch September 3, 2026 23:46
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