feat(codegen): wire logArchive from env so the Studio archive is turnkey - #156
Conversation
The `logArchive` WorkerOption existed but the generated worker entry never passed it through, so a Vite-first / scaffolded app couldn't reach the Studio's Logs → Archive feed without hand-editing generated code. - `@lunora/runtime`: add `resolveLogArchiveFromEnv(env)` — builds the `LogArchiveConfig` from `LUNORA_LOG_ARCHIVE_TABLE` (+ optional `LUNORA_LOG_ARCHIVE_NAMESPACE`), mirroring how the `R2_SQL_*` credentials already come from env. Returns undefined (→ "not configured") until the operator names the table. - `@lunora/codegen`: the generated worker entry now imports the helper and sets `options.logArchive = resolveLogArchiveFromEnv(env)` unconditionally, so every scaffolded app supports the archive by setting one env var. Golden fixture regenerated. - Docs: document the env-var opt-in for the scaffolded flow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
✅ Deploy Preview for lunorash ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for following the naming conventions! 🙏 |
|
Thank you for confirming the Contributor License Agreement! 🙏 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (4)
WalkthroughThe runtime adds environment-based durable archive configuration, generated workers pass it into ChangesLog archive configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant GeneratedApp
participant resolveLogArchiveFromEnv
participant WorkerOptions
participant StudioArchive
GeneratedApp->>resolveLogArchiveFromEnv: Read environment configuration
resolveLogArchiveFromEnv-->>GeneratedApp: Return LogArchiveConfig or undefined
GeneratedApp->>WorkerOptions: Set options.logArchive
WorkerOptions->>StudioArchive: Provide archive configuration
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
Closes the one actionable gap left after the durable-archive Studio feed (#155): the
logArchiveWorkerOptionexisted and the whole read path worked, but codegen never passed it through — so a Vite-first / scaffolded app couldn't reach the Studio's Logs → Archive feed without hand-editing generated code.What changed
@lunora/runtime— newresolveLogArchiveFromEnv(env): builds theLogArchiveConfigfromLUNORA_LOG_ARCHIVE_TABLE(+ optionalLUNORA_LOG_ARCHIVE_NAMESPACE), mirroring how the R2 SQL credentials already come from env (R2_SQL_*). Returnsundefined— so the feed stays "not configured" — until the operator names the table. (AcolumnMapoverride isn't env-expressible; a hand-written worker still passeslogArchivetocreateWorkerdirectly.)@lunora/codegen— the generated worker entry now imports the helper and setsoptions.logArchive = resolveLogArchiveFromEnv(env)unconditionally, so every scaffolded app supports the archive by setting one env var. Golden fixture regenerated (only the import line + the one wiring line change).Result
Turnkey: set
R2_SQL_ACCOUNT_ID/R2_SQL_TOKEN/R2_SQL_BUCKET+LUNORA_LOG_ARCHIVE_TABLE, and the Studio Archive tab lights up — no code edits.Tests
@lunora/runtime: 4 newresolveLogArchiveFromEnvcases (unset → undefined, table→config, +namespace, empty/non-string/non-object rejected, empty-namespace dropped) + existing route suite. Full suite 575 green.@lunora/codegen: golden snapshot regenerated + all variant emit tests. Full suite 838 green.lint:types+ eslint (--max-warnings=0) clean; API snapshots updated (additions only); repo-wide prettier clean.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation