Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fioncat
Copy link
Owner

@fioncat fioncat commented Mar 28, 2025

No description provided.

@fioncat fioncat requested a review from Copilot March 28, 2025 07:27
@fioncat fioncat linked an issue Mar 28, 2025 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how the application manages configuration by replacing lifetime parameters with shared ownership via Rc to support live-reload functionality. Key changes include:

  • Removing explicit lifetime annotations in UI and tree-related modules in favor of Rc-based configuration.
  • Updating constructors and method calls across multiple files to clone Rc as needed.
  • Adjusting configuration access in data rendering and parser invocations to accommodate the new Rc usage.

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ui/tree_overview.rs Removed lifetime parameters and adjusted constructors to accept Rc.
src/ui/popup.rs Updated Popup to use Rc instead of borrowed references.
src/ui/header.rs Changed Header to operate with Rc; consider revisiting unnecessary cloning.
src/ui/footer.rs Refactored Footer to accept Rc.
src/ui/data_block.rs Updated DataBlock to work with Rc and modified data rendering accordingly.
src/ui/app.rs Updated App to utilize Rc across components and adjusted Edit initialization.
src/tree.rs Modified tree parsing and conversion to support Rc usage.
src/main.rs Initialized configuration as Rc and propagated it to the application components.
Files not reviewed (1)
  • src/live_reload.rs: Language not supported
Comments suppressed due to low confidence (1)

src/ui/header.rs:55

  • [nitpick] The explicit cfg.clone() may be redundant since cfg is already an Rc; consider using cfg.header.format directly to simplify the code.
let header_format = &cfg.clone().header.format;

@fioncat fioncat requested a review from Copilot March 31, 2025 03:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for live-reloading the TUI when the underlying file is changed. It refactors the UI modules to use shared configuration via Rc, integrates a new live_reload module with a FileWatcher, and updates the application logic to reload the tree upon file updates.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ui/tree_overview.rs Replaces lifetime parameters with Rc and updates tree reload logic.
src/ui/popup.rs Converts configuration reference to Rc.
src/ui/header.rs Updates header construction to use a cloned Rc.
src/ui/footer.rs Refactors to use Rc instead of lifetimes.
src/ui/data_block.rs Updates configuration handling and rendering to adopt Rc.
src/ui/app.rs Integrates FileWatcher into the app, adjusts refresh logic, and renames copy message to foot_message.
src/tree.rs Removes lifetime annotations and propagates Rc usage in tree parsing.
src/main.rs Adjusts config usage with Rc, integrates live_reload, and passes FileWatcher to App.
src/live_reload.rs Introduces file watching functionality using the notify crate and updates live-reload behavior.
src/debug.rs Minor update to ensure logs include a newline.
src/cmd.rs Adds command-line support for live reloading.
Cargo.toml Adds the notify crate as a dependency.

data_lock.set_data(s);
drop(data_lock);
}
EventKind::Remove(_) => bail!("the file {} was removed by user", path.display()),
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

Handling file removal by bailing out of the watcher thread may interrupt live-reload functionality unexpectedly. Consider handling file removal gracefully (for example, by notifying the user and optionally attempting to re-establish the watcher) rather than exiting the watcher thread.

Suggested change
EventKind::Remove(_) => bail!("the file {} was removed by user", path.display()),
EventKind::Remove(_) => {
debug!("the file {} was removed by user, attempting to re-watch", path.display());
watcher.watch(&path, RecursiveMode::NonRecursive)?;
},

Copilot uses AI. Check for mistakes.
@fioncat fioncat merged commit 34465bd into main Mar 31, 2025
2 checks passed
@fioncat fioncat deleted the feat/live-reload branch March 31, 2025 03:10
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jun 13, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ubi:fioncat/otree](https://github.com/fioncat/otree) | minor | `0.3.1` -> `0.4.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>fioncat/otree (ubi:fioncat/otree)</summary>

### [`v0.4.0`](https://github.com/fioncat/otree/releases/tag/v0.4.0)

[Compare Source](fioncat/otree@v0.3.1...v0.4.0)

##### Features

-   Command: Add new flag `--debug`, to write some debug logs to a file.
-   UI: Add `--live-reload` option, to watch file changes and update tui ([#&#8203;63](fioncat/otree#63)).
-   Release: Add Windows prebuilt binary (**unstable**, require more testing).

#### What's Changed

-   feat(cmd): support `--debug` flag to write debug logs by [@&#8203;fioncat](https://github.com/fioncat) in fioncat/otree#67
-   feat: support live-reload tui when file is changed by [@&#8203;fioncat](https://github.com/fioncat) in fioncat/otree#68

**Full Changelog**: fioncat/otree@v0.3.1...v0.4.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4zMi43IiwidXBkYXRlZEluVmVyIjoiNDAuMzIuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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.

Live Reload

2 participants