Skip to content

Conversation

@mkh-user
Copy link
Member

@mkh-user mkh-user commented Sep 25, 2025

Type of Change

  • Refactoring

Description

Moves import_mode and install_extension to EditorAPI and ExtensionCore from action script helpers, because these functions are useful and internal.

Testing

Nothing

Impact

Nothing

Additional Information

This is a refactor for #106

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings
  • Changes were added to CHANGELOG

Summary by CodeRabbit

  • New Features

    • Unified workflows to install extensions and import modes, with validation, clear error messages, automatic folder creation, and completion notifications.
    • Prompts to reload after successful extension installation for immediate availability.
  • Refactor

    • Delegated install/import logic to centralized services for greater reliability and consistency.
    • Dialog windows now close cleanly on request, ensuring proper cleanup and a smoother user experience.

@mkh-user mkh-user self-assigned this Sep 25, 2025
@mkh-user mkh-user added the action scripts Official action scripts or action scripts features label Sep 25, 2025
@mkh-user mkh-user added this to the Text Forge 0.2 milestone Sep 25, 2025
@mkh-user mkh-user moved this from Needs Review to In Progress in Release: Text Forge 1.0 Sep 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

Refactors extension and mode import flows to delegate unpack/install logic to centralized APIs. Scenes now call Extensions.install_extension(path) and EditorAPI.import_mode(path). Adds a close_requested→queue_free connection in the mode manager scene. Introduces new install/import methods with validation, ZIP handling, directory creation, reloads, and user notifications.

Changes

Cohort / File(s) Summary
Delegate extension installation to core
action_scripts/scenes/extensions.gd
Replaces inline ZIP unpack and reload logic with a call to Extensions.install_extension(path); removes reload prompt and related helper.
Centralize mode import and simplify closing
action_scripts/scenes/mode_manager.gd
Replaces manual ZIP-based _import_mode with Global.get_editor_api().import_mode(path); removes _close() and uses queue_free() where needed.
Scene close handling
action_scripts/scenes/mode_manager.tscn
Connects close_requested to queue_free for automatic cleanup.
Core extension installer
core/extensions/extensions.gd
Adds install_extension(path: String) to validate .tfx, unpack ZIP to extensions dir, prompt/reload, and notify.
Editor API mode importer
core/scripts/editor_api.gd
Adds import_mode(path: String) to validate .tfmode, unpack ZIP to user://modes, reload modes, and notify on success/error.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant ExtensionsUI as Extensions UI
  participant Extensions as Extensions Core
  participant FS as FileSystem/ZIP
  participant Editor as Editor Runtime

  User->>ExtensionsUI: Select .tfx file
  ExtensionsUI->>Extensions: install_extension(path)
  Extensions->>FS: Open ZIP, create dirs, write files
  FS-->>Extensions: Extraction result
  Extensions->>Editor: Reload extensions/modes
  Editor-->>Extensions: Reload complete
  Extensions->>User: Notify completion / prompt to reload
Loading
sequenceDiagram
  autonumber
  actor User
  participant ModeMgrUI as Mode Manager UI
  participant EditorAPI as Editor API
  participant FS as FileSystem/ZIP
  participant Editor as Editor Runtime

  User->>ModeMgrUI: Import .tfmode
  ModeMgrUI->>EditorAPI: import_mode(path)
  EditorAPI->>FS: Validate, open ZIP, create dirs, write files
  FS-->>EditorAPI: Extraction result
  EditorAPI->>Editor: Reload modes
  Editor-->>EditorAPI: Reload complete
  EditorAPI->>User: Notify success or error
  User-->>ModeMgrUI: Close window
  ModeMgrUI->>ModeMgrUI: queue_free()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through zips with tidy glee,
From modes to extensions—centralized, you see.
No more loose threads, just one clean trail,
Reloads chimed in a carrot-scale.
With queue_free whispers, windows close—
Thump-thump! The pipeline smoothly flows. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary refactoring change by stating that mode and extension installation logic has been relocated to central scripts, making it clear, specific, and aligned with the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-mode-extension-installer

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.

Copy link
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: 2

🧹 Nitpick comments (3)
core/extensions/extensions.gd (1)

100-103: Don’t reload modes after installing extensions.

Reloading modes here is likely unintended; extensions should be reloaded (you already prompt to do so). Remove the modes reload to avoid extra work and confusion.

The diff above removes the reload_modes() call. If you do want an immediate reload, call setup_extensions() directly instead of reloading modes.

action_scripts/scenes/mode_manager.gd (1)

37-39: Delegate import: OK. Align file dialog filters to the new API.

EditorAPI.import_mode only accepts .tfmode. Update the file dialog filter (Line 34) to drop “*.zip” to prevent “Invalid mode file!” errors when users pick a .zip.

Also consider updating export filters (Lines 59 and 124) to prefer .tfmode to keep import/export consistent.

action_scripts/scenes/extensions.gd (1)

52-52: Good delegation. Sync the open-file filter with the stricter installer.

Extensions.install_extension now rejects non-.tfx. Update the file dialog filter (Line 48) from ".tfx,.zip" to "*.tfx" to avoid user-facing errors.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74085d4 and d5baf08.

📒 Files selected for processing (5)
  • action_scripts/scenes/extensions.gd (1 hunks)
  • action_scripts/scenes/mode_manager.gd (2 hunks)
  • action_scripts/scenes/mode_manager.tscn (1 hunks)
  • core/extensions/extensions.gd (1 hunks)
  • core/scripts/editor_api.gd (1 hunks)
🔇 Additional comments (2)
action_scripts/scenes/mode_manager.tscn (1)

105-105: Good: close requests free the window immediately.

Connecting Window.close_requested to queue_free on the node itself is correct and matches the script changes.

action_scripts/scenes/mode_manager.gd (1)

55-55: LGTM: use queue_free after opening the script.

Matches the scene’s close_request handling and cleans up promptly.

@mkh-user mkh-user merged commit 24556dd into Main Sep 25, 2025
2 checks passed
@mkh-user mkh-user deleted the add-mode-extension-installer branch September 25, 2025 14:27
@github-project-automation github-project-automation bot moved this from In Progress to Completed in Release: Text Forge 1.0 Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action scripts Official action scripts or action scripts features

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants