Skip to content

load preference from mod#328

Merged
meganetaaan merged 2 commits intostack-chan:dev/v1.0from
stc1988:feature/mod_preference
Jun 8, 2025
Merged

load preference from mod#328
meganetaaan merged 2 commits intostack-chan:dev/v1.0from
stc1988:feature/mod_preference

Conversation

@stc1988
Copy link
Copy Markdown
Contributor

@stc1988 stc1988 commented Jun 7, 2025

#295 の対応になります。詳細はそちらを参照お願いします。

上記以外の変更点として、Modulesモジュールを使うとpreloadができなくなるため、loadPreferences を独立させました

Summary by CodeRabbit

  • New Features

    • Improved preference loading with enhanced merging and category filtering for user settings.
  • Refactor

    • Updated internal handling of preferences to streamline configuration management.
    • Changed preference loading imports to a new utility module.
  • Chores

    • Removed unused code and updated import sources for preference utilities.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 7, 2025

Walkthrough

The changes move the loadPreferences function from the stackchan-util module to a new loadPreference module. All imports of this function across the codebase are updated to reflect this relocation. Additionally, a commented-out TODO line is removed from the main robot creation logic. No other logic or functionality is altered.

Changes

Files/Groups Change Summary
firmware/stackchan/utilities/loadPreference.ts New module added with loadPreferences function for loading and merging preference settings.
firmware/stackchan/utilities/stackchan-util.ts Removed loadPreferences function and related imports; retained other utility functions.
firmware/mods/ai_stackchan/mod.js
firmware/mods/ai_stackchan_api/mod.js
firmware/mods/chatgpt/mod.js
firmware/stackchan/main.ts
Updated imports to use default import from 'loadPreference' instead of named import from 'stackchan-util'. Removed a commented-out TODO in main.ts.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Any Module (e.g., ai_stackchan)
    participant LoadPreference as loadPreference.ts
    participant CoreConfig as core config
    participant ModuleConfig as module config (optional)
    participant Preference as Preference store

    Caller->>LoadPreference: loadPreferences(category)
    LoadPreference->>CoreConfig: Import base config
    LoadPreference->>ModuleConfig: Import module config (if available)
    LoadPreference->>LoadPreference: Clone configs and merge
    loop For each key in category
        LoadPreference->>Preference: get(key)
        Preference-->>LoadPreference: value (if exists)
        LoadPreference->>LoadPreference: Apply constructor (if needed)
    end
    LoadPreference-->>Caller: Return merged preferences object
Loading

Poem

In the warren of code, a function hopped away—
From util to its own home, it found a brighter day.
Preferences now load with a single, clear call,
No more confusion—just one rabbit for all!
🐇✨
Hop, hop, hooray for tidy code’s ballet!


📜 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 ef9d541 and 9b9a2a6.

📒 Files selected for processing (1)
  • firmware/stackchan/utilities/loadPreference.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • firmware/stackchan/utilities/loadPreference.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 198b581 and ef9d541.

📒 Files selected for processing (6)
  • firmware/mods/ai_stackchan/mod.js (1 hunks)
  • firmware/mods/ai_stackchan_api/mod.js (1 hunks)
  • firmware/mods/chatgpt/mod.js (1 hunks)
  • firmware/stackchan/main.ts (1 hunks)
  • firmware/stackchan/utilities/loadPreference.ts (1 hunks)
  • firmware/stackchan/utilities/stackchan-util.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • firmware/stackchan/utilities/stackchan-util.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
firmware/stackchan/utilities/loadPreference.ts (1)
firmware/stackchan/utilities/consts.ts (2)
  • DOMAIN (1-7)
  • PREF_KEYS (9-27)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (5)
firmware/mods/chatgpt/mod.js (1)

2-3: LGTM! Import change is consistent with the refactor.

The change from named import to default import aligns with the extraction of loadPreferences to a standalone module.

firmware/mods/ai_stackchan/mod.js (1)

3-3: LGTM! Import change aligns with the refactor.

The default import from the new loadPreference module is correct and maintains existing functionality.

firmware/mods/ai_stackchan_api/mod.js (1)

3-4: LGTM! Clean separation of imports.

Good separation - other utilities remain in stackchan-util while loadPreferences is correctly imported from the new standalone module.

firmware/stackchan/main.ts (1)

22-23: LGTM! Import refactor is consistent and clean.

The import separation maintains existing functionality while properly utilizing the new standalone loadPreference module.

firmware/stackchan/utilities/loadPreference.ts (1)

1-8: LGTM! Imports and setup are correctly structured.

The imports are comprehensive and the modConfig initialization properly handles optional module configuration.

Comment thread firmware/stackchan/utilities/loadPreference.ts
Copy link
Copy Markdown
Collaborator

@meganetaaan meganetaaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod側のconfigが上書きで反映されることを確認しました。LGTMです!

@meganetaaan meganetaaan merged commit 3a26806 into stack-chan:dev/v1.0 Jun 8, 2025
3 checks passed
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.

2 participants