Uh oh!
There was an error while loading. Please reload this page.
ADFA-3802 make documentation bookshelf dynamic - #1353
Conversation
📝 WalkthroughWalkthroughAdds /pr/bs routing and a two-stage bookshelf handler: a wrapper that optionally clears template cache and gates error sends, plus realHandleBsEndpoint which queries the debug DB for a single JSON row, lazily caches a Pebble template ID, renders via instantiatePebbleTemplate with added debug logs, and writes the response. ChangesBookshelf Endpoint Feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/src/main/java/com/itsaky/androidide/localWebServer/WebServer.kt`:
- Around line 696-708: The code in WebServer.kt overwrites the existing cursor
when running the template-ID query (affecting bookshelfTemplateId) and never
closes the original cursor; fix by ensuring each Cursor is closed — either use a
second local variable for the template query (e.g., templateCursor) or wrap each
rawQuery result in a Kotlin use { } block so cursor.close() is called
automatically before assigning or returning; update the block around the
rawQuery/cursor.moveToFirst()/getInt(0) logic that sets bookshelfTemplateId and
any sendError branches to close the appropriate cursor(s).
- Around line 67-69: When the DB handle is reopened/rotated (the block that
reassigns the database variable), clear the template caches so old templates
from the previous DB aren’t reused: call templateCache.clear() and reset
bookshelfTemplateId = -1 immediately after the database swap (the same place
where the code reopens/assigns database). This ensures PebbleTemplate entries in
templateCache and the cached bookshelfTemplateId are invalidated when the
database changes.
- Around line 567-578: The catch block can append a second 500 because
outputStarted is only set true after realHandleBsEndpoint returns; modify the
flow so outputStarted is set to true as soon as any headers/body are written
(i.e., inside the write path) rather than only on return. Concretely, update
realHandleBsEndpoint (or the helper that calls writeNormalToClient) to accept a
mutable flag (e.g., AtomicBoolean or a setter lambda) or return a result object
so it flips outputStarted to true immediately when the first write/flush
happens, then keep the existing try/catch in handleBsEndpoint to rely on that
flag. Ensure references: handleBsEndpoint, realHandleBsEndpoint, and the write
method (writeNormalToClient) are changed accordingly so the catch sees the
correct outputStarted state.
- Around line 713-721: The catch block that logs the fetch error and calls
sendError must stop further processing so instantiatePebbleTemplate(...) is not
called with uninitialized jsonText or bookshelfTemplateId; modify the catch
(Exception e) handling around the fetch to, after logging and calling
sendError(writer, output, 500, ...), immediately return (or otherwise
short-circuit) from the surrounding method so cursor.close() remains in finally
and instantiatePebbleTemplate(...) is never reached when an exception occurred.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7f80d995-fb24-456b-a5b1-4809b7f61d43
📒 Files selected for processing (1)
app/src/main/java/com/itsaky/androidide/localWebServer/WebServer.kt
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @davidschachterADFA. The following files were modified: * `app/src/main/java/com/itsaky/androidide/localWebServer/WebServer.kt`
…kshelf-dynamic' into ADFA-3802-Make-documentation-bookshelf-dynamic
added const names for 500, 404 error codes
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* WIP added code for dynamic bookshelf * first working version of dynamic bookshelf * 📝 Add docstrings to `ADFA-3802-Make-documentation-bookshelf-dynamic` Docstrings generation was requested by @davidschachterADFA. The following files were modified: * `app/src/main/java/com/itsaky/androidide/localWebServer/WebServer.kt` * fixed issues from the PR 1353 * centralized cursor row check added const names for 500, 404 error codes --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: davidschachterADFA <davidschachter@appdevforall.org>
First working version of dynamic bookshelf from curl
TODO: Need to add HTML template to the documentation.db file