Skip to content

Implements decofile hotswap apis#993

Merged
mcandeia merged 1 commit into
mainfrom
deconfig/hot-swap
Nov 13, 2025
Merged

Implements decofile hotswap apis#993
mcandeia merged 1 commit into
mainfrom
deconfig/hot-swap

Conversation

@mcandeia

@mcandeia mcandeia commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added a reload endpoint for triggering decofile state synchronization with optional delay parameters.
    • Endpoint responds with confirmation status for tracking requests.
  • Refactor

    • Streamlined state update logic to eliminate redundant processing and improve system efficiency.

Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 13, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This change introduces a debounced state update mechanism for the decofile provider and exposes it via a new HTTP endpoint. The fs provider refactors its update logic into a reusable debounced function and adds a public notify() method, while a new reload route handler allows external systems to trigger state synchronization with optional delay scheduling.

Changes

Cohort / File(s) Summary
Decofile Provider Refactoring
engine/decofile/fs.ts
Extracts debounced updateState function to outer scope for shared use, removes duplicate logic from filesystem watcher loop, and adds public notify() method to the returned provider object for programmatic state updates.
Route Integration and Reload Endpoint
runtime/handler.tsx
runtime/routes/reload.ts
Registers new route /.decofile/reload in handler configuration; adds corresponding route handler that accepts a query parameter for delay, schedules a deferred notify() call on the provider state, and responds with confirmation JSON.

Sequence Diagram

sequenceDiagram
    participant ext as External System
    participant http as HTTP Endpoint<br/>(reload.ts)
    participant deco as DecofileProvider<br/>(notify)
    participant updater as Debounced<br/>updateState
    participant cb as onChange<br/>Callbacks

    ext->>http: GET /.decofile/reload?delay=100
    http->>http: Parse delay parameter
    http-->>ext: { "scheduled": true }
    http->>deco: Schedule notify() after delay
    deco->>updater: Invoke (debounced)
    updater->>updater: Read & parse file
    updater->>updater: Update in-memory state
    updater->>cb: Notify all listeners
    cb-->>deco: Callbacks executed
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Verify the debounce implementation in fs.ts correctly shares state and prevents callback duplication when called in rapid succession
  • Confirm the notify() method signature and promise resolution behavior align with the reload handler's expectations
  • Check that the delay query parameter parsing handles edge cases (negative values, non-numeric input)

Poem

🐰 A notify button hops into view,
With scheduled delays and JSON too,
The decofile state can now be poked,
External triggers keep all in sync—relocation soaked!
Debounced magic in a fluffy refactor brew. 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deconfig/hot-swap

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b335292 and b009ef4.

📒 Files selected for processing (3)
  • engine/decofile/fs.ts (2 hunks)
  • runtime/handler.tsx (2 hunks)
  • runtime/routes/reload.ts (1 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 1.128.3 update
  • 🎉 for Minor 1.129.0 update
  • 🚀 for Major 2.0.0 update

@mcandeia mcandeia merged commit 5f0e38d into main Nov 13, 2025
4 of 5 checks passed
@mcandeia mcandeia deleted the deconfig/hot-swap branch November 13, 2025 19:18
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