Skip to content

feat: add contextual ?reply - #145

Closed
Musheer360 wants to merge 8 commits into
masterfrom
feature/contextual-reply
Closed

feat: add contextual ?reply#145
Musheer360 wants to merge 8 commits into
masterfrom
feature/contextual-reply

Conversation

@Musheer360

Copy link
Copy Markdown
Owner

Summary

  • Add contextual ?reply when the composer contains only the trigger.
  • Preserve the existing message?reply flow.
  • Capture a bounded, ephemeral accessibility snapshot and generate one strictly validated reply.
  • Fail safely when context or provider output is unusable.

Validation

  • ./gradlew test
  • ./gradlew lint
  • ./gradlew assemblePreview
  • git diff --check

No emulator was started. Real-device testing is still needed to verify app-specific accessibility trees; unsupported layouts leave the composer unchanged.

Copilot AI lite review requested due to automatic review settings August 20, 2026 09:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new contextual ?reply flow that, when the composer contains only the trigger, captures a bounded accessibility snapshot of nearby conversation text and generates exactly one strictly validated reply, while preserving the existing message?reply behavior.

Changes:

  • Introduces a detached accessibility snapshot model + generic conversation context extractor (with unit tests).
  • Adds a strict structured-output “contextual reply” command path and wires it into AssistantService.
  • Adds new user-facing strings and structured-output normalization utilities (with tests).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/test/java/com/musheer360/swiftslate/service/ConversationContextTest.kt Adds coverage for generic conversation context extraction and adapter preference.
app/src/test/java/com/musheer360/swiftslate/api/ApiClientUtilsTest.kt Tests trimming/bounds behavior for structured-text normalization.
app/src/main/res/values/strings.xml Adds new (English-only) contextual-reply toast/error strings.
app/src/main/java/com/musheer360/swiftslate/service/ConversationContext.kt New snapshot DTOs and generic extractor for nearby incoming/outgoing messages.
app/src/main/java/com/musheer360/swiftslate/service/CommandRunner.kt Adds strict structured-output validation and a dedicated contextual reply runner.
app/src/main/java/com/musheer360/swiftslate/service/AssistantService.kt Detects ?reply-only input, snapshots active window, and runs contextual reply flow.
app/src/main/java/com/musheer360/swiftslate/service/AccessibilityConversationSnapshot.kt Copies AccessibilityNodeInfo tree into a detached, budgeted snapshot.
app/src/main/java/com/musheer360/swiftslate/api/ApiClientUtils.kt Adds normalizeStructuredText helper used by strict contextual reply validation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +64 to +69
val key = text.lowercase(Locale.ROOT)
val previous = candidates[key]
candidates[key] = if (previous == null) candidate else previous.copy(
incoming = previous.incoming || candidate.incoming,
outgoing = previous.outgoing || candidate.outgoing
)
Comment on lines +12 to +13
if (depth > 32 || budget[0] >= 500) {
return ConversationNodeSnapshot(
Repository owner deleted a comment from github-actions Bot Aug 20, 2026
Repository owner deleted a comment from github-actions Bot Aug 20, 2026
Repository owner deleted a comment from github-actions Bot Aug 20, 2026
Repository owner deleted a comment from github-actions Bot Aug 20, 2026
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

📦 Preview APK — PR #145 · 013f885 · 1.43 MB

Direct download · Run · SwiftSlate-preview-pr145.zip → single .apk, no folders · expires 14d

Unzip → installs as SwiftSlate Preview (com.musheer360.swiftslate.preview), separate from stable. Enable in Settings → Accessibility.

Musheer360 added 5 commits August 21, 2026 01:45
- Rename inline trigger to ?answer (Generate a reply to this message)
- Keep ?reply as contextual-only (?reply alone reads chat, replies to latest incoming)
- Split AssistantService routing: reply requires empty, answer requires text
- Guide hello?reply to toast 'Use ?answer'
- No migration: fresh installs seed both, existing keep old ?reply inline + get ?answer seeded; docs note manual delete
- Update README and strings
… reply

- OverlayToast: remove Android Toast fallback, log and drop instead; service already uses overlayToast.show and Compose uses SlateToast
- strings: make toast_reply_no_context, toast_reply_needs_empty, error_reply_invalid_response translatable and add translations for 40 locales (ar, bg, ca, cs, da, de, el, es, et, fa, fi, fr, hi, hr, hu, in, it, iw, ja, ko, lt, lv, ms, nb, nl, pl, pt, pt-rBR, ro, ru, sk, sl, sr, sv, th, tr, uk, vi, zh, zh-rCN)
Check isModelRefusal on raw provider text before strict JSON extraction so plain-text refusals (not JSON) surface as Refusal -> error_safety_blocked instead of error_reply_invalid_response
- Snapshot now captures boundsLeft/boundsRight (was only top/bottom)
- Generic extractor uses left<150 => Incoming, left>=150 => You as fallback when no resource-id markers (verified on Baddie D'Silva dump: left 49 vs 414+)
- Keeps adapter escape hatch, no breaking existing tests (boundsLeft null falls back to markers)
- Add debug logs for AI command and contextual snapshot (package/snapshotText/latestIncoming) for manual preview testing with Baddie/self
@Musheer360 Musheer360 closed this Aug 21, 2026
@Musheer360
Musheer360 deleted the feature/contextual-reply branch August 21, 2026 06:52
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