feat: add contextual ?reply - #145
Closed
Musheer360 wants to merge 8 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
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( |
Contributor
📦 Preview APK — PR #145 ·
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
?replywhen the composer contains only the trigger.message?replyflow.Validation
./gradlew test./gradlew lint./gradlew assemblePreviewgit diff --checkNo emulator was started. Real-device testing is still needed to verify app-specific accessibility trees; unsupported layouts leave the composer unchanged.