feat: experimental Termux/Android compatibility - #497
Open
PSYCH0patch wants to merge 1 commit into
Open
Conversation
Adds a Node.js built-in sqlite fallback so the server runs on Termux without needing better-sqlite3 native compilation or the Android NDK. Changes: - Move better-sqlite3 to optionalDependencies in server and desktop packages so npm install no longer fails on android platforms. - Add a node:sqlite adapter used when process.platform === 'android', with a SAVEPOINT-based transaction wrapper that supports nesting. - Default behavior on Linux/macOS/Windows/desktop is unchanged: the better-sqlite3 driver is still selected via the same factory hook, and connectDb still accepts an injected factory for tests. - Add test coverage for the fallback adapter, including nested transactions and rollback semantics. - Add docs/install/android-termux.md and a one-line README link so Android users have a supported install path. Refs tashfeenahmed#308
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.
Closes #308
Adds a Node.js built-in sqlite fallback so the server runs on Termux without needing
better-sqlite3native compilation or the Android NDK.Changes
better-sqlite3tooptionalDependenciesinserveranddesktoppackages sonpm installno longer fails onandroidplatforms.node:sqliteadapter used whenprocess.platform === 'android', with aSAVEPOINT-based transaction wrapper that supports nesting.better-sqlite3driver is still selected via the same factory hook, andconnectDbstill accepts an injected factory for tests.docs/install/android-termux.mdand a one-line README link so Android users have a supported install path.Scope
Single concern: make the server start cleanly on Termux without touching desktop/server behavior on other platforms.
Testing
server/src/__tests__/db/node-sqlite-fallback.test.tsverifies thenode:sqliteadapter works and correctly handles nestedSAVEPOINTtransactions (commit + rollback semantics).Verified end-to-end from a clean clone
Reproduced the full user flow on a fresh Termux install (Android 10+, Node LTS via
nodejs-lts):git clone -b feat/termux-compatibility https://github.com/PSYCH0patch/freellmapi.git cd freellmapi npm install npm run devResult:
npm installcompletes in ~33s with no native compile step:3001, dashboard on:5173GYP_DEFINES, no manual rebuild requiredNotes for reviewers
import 'better-sqlite3'directly (bypassing the adapter) can't be loaded because the package isn't installed on Android. These are development-only fixtures, not part of any runtime path, and refactoring them to use the adapter is intentionally left out of scope to keep this PR small. Happy to do that as a follow-up if you'd like.optionalDependenciesmeans desktop/server installs on Linux/macOS/Windows still getbetter-sqlite3exactly as before — nothing changes for existing users.