Skip to content

Feature/android sdk#2

Open
berkaymenekse wants to merge 5 commits intomololab:mainfrom
berkaymenekse:feature/android-sdk
Open

Feature/android sdk#2
berkaymenekse wants to merge 5 commits intomololab:mainfrom
berkaymenekse:feature/android-sdk

Conversation

@berkaymenekse
Copy link

No description provided.

Track used tables from the LLM response and generate a mermaid ER diagram in the streamed chat completion payload.

Made-with: Cursor
Added 'used_tables' and 'diagram' fields to Query and GeneratedSQL types to support relationship diagram generation. Updated related parsing and response handling to accommodate these changes. Improved documentation to reflect the new structure.
- SDK: WebSocket client connecting to AloDB server
- QuerySafetyFilter: whitelist-based guard, row data never sent to server
- SchemaQueryTranslator: converts PostgreSQL information_schema queries to SQLite PRAGMA equivalents
- DatabaseDriver: interface with SQLiteDriver and RoomDriver implementations
- SessionDataManager: session-scoped data write + verified DELETE on disconnect/logout
- AloDBClient: Builder API with connect/chat/trigger/write/disconnect
- Trigger system: named triggers for proactive chatbot messages on page navigation
- Sample app: full chat UI with streaming, thinking indicator, auto-execute queries

Made-with: Cursor
Critical fixes:
- WebSocketManager: make handleQueryRequest/executeAndSend suspend and
  wrap driver.execute() in withContext(Dispatchers.IO) to prevent main
  thread DB violations
- MainActivity: move autoExecuteQueries to lifecycleScope.launch(Dispatchers.IO)
  with Dispatchers.Main for UI updates, eliminating main thread blocking
- ChatMessage: change var text to val text; use immutable copy() in
  appendStreamingDelta to fix thread-safety across WebSocket and UI threads
- QuerySafetyFilter: replace start-of-string ^ regex with DML_ANYWHERE
  full-text scan to block multi-statement and WITH-clause DML injection
- sample/build.gradle.kts: replace annotationProcessor with ksp plugin
  (annotationProcessor does not work for Kotlin Room projects)

Medium fixes:
- AloDBClient: disconnect previous WebSocketManager (with OkHttpClient
  thread pool shutdown) before creating new one on connect(); run
  clearSessionData on clientScope (Dispatchers.IO) to avoid main thread
  DB ops in onDestroy()
- RoomDriver.clearTable: use compileStatement + executeUpdateDelete() to
  return actual deleted row count instead of pre-delete row count
- SchemaQueryTranslator: log a warning when table name extraction falls
  back to "unknown" instead of failing silently

Minor fixes:
- ChatAdapter: move all hardcoded Color.parseColor calls to colors.xml
  and read via ContextCompat.getColor() once per bind
- settings.gradle.kts: rename dependencyResolution to
  dependencyResolutionManagement (invalid block name)
- build.gradle.kts: register KSP plugin at root level with apply false

Made-with: Cursor
When sendQueryResults is enabled via Builder, SELECT query results are
sent back to the LLM so it can produce personalized responses. Default
is false (schema-only mode, no row data leaves the device).

DML statements (INSERT/UPDATE/DELETE/DROP/CREATE/ALTER) are always
blocked regardless of the flag.

- AloDBConfig: add sendQueryResults field (default false)
- AloDBClient.Builder: add sendQueryResults(enabled) method
- QuerySafetyFilter: add checkSelectOnly() for permissive SELECT mode
- WebSocketManager: route to correct filter based on flag

Made-with: Cursor
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