Skip to content

feat: 015 — delete focus from tray - #13

Merged
archae0pteryx merged 2 commits into
mainfrom
feat/015-delete-focus-tray
May 2, 2026
Merged

feat: 015 — delete focus from tray#13
archae0pteryx merged 2 commits into
mainfrom
feat/015-delete-focus-tray

Conversation

@archae0pteryx

@archae0pteryx archae0pteryx commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Each focus item in the tray NSMenu is now a Submenu; hovering the title shows an arrow
  • Submenu contains a single "Delete "{title}"…" item
  • Clicking shows a native macOS confirmation dialog (tauri-plugin-dialog)
  • Confirming calls the existing delete_focus command → directory removed → file watcher fires → tray rebuilds + pig disappears within 1s
  • Cancelling does nothing

Implementation notes

  • tauri-plugin-dialog = "2" added to Cargo.toml and registered in app setup
  • handle_delete runs in a spawned thread (not the menu event dispatch thread) to allow blocking dialog API
  • Focus title looked up from managed CommandsState before showing dialog (gives a human-readable confirmation message)
  • Delete prefix tray-delete-<focus_id_string> is stored in the menu item ID

Test plan

  • task check green (CI)
  • Open tray → each focus shows a submenu arrow
  • Hover focus name → "Delete "{title}"…" appears
  • Click delete item → native macOS dialog appears with correct title
  • Cancel → nothing deleted, pig still present
  • Confirm → focus directory removed, pig disappears within 1s, tray menu updates

Closes #8

Summary by CodeRabbit

  • New Features
    • Delete individual focuses directly from the system tray via per-focus submenu entries, with a confirmation dialog to prevent accidental deletion.
  • User Experience
    • Tray menu restructured to group per-focus actions into submenus for clearer, more accessible controls.
  • Chores
    • Enabled native confirmation dialog support to power the new delete flow.

Each focus item in the tray menu is now a Submenu. Hovering the focus
title reveals a "Delete \"<title>\"…" item. Clicking it shows a native
macOS confirmation dialog (tauri-plugin-dialog); confirming calls
delete_focus, removing the directory. The file watcher then fires and
the tray rebuilds + pig disappears within 1s.

- tauri-plugin-dialog added; registered in app setup
- Focus items replaced with Submenus containing a delete item per focus
- Delete event handler spawns a background thread: looks up title from
  managed state, shows blocking confirm dialog, then calls delete_focus
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: efd02a6c-710c-46f1-b797-0ad28a05ba69

📥 Commits

Reviewing files that changed from the base of the PR and between 3b65a7d and d286798.

📒 Files selected for processing (1)
  • src-tauri/src/app/tray.rs

📝 Walkthrough

Walkthrough

Adds tauri-plugin-dialog, registers it with the Tauri Builder, converts per-focus tray items into submenus with a "Delete…" action, and implements a blocking confirmation dialog flow that calls the existing delete_focus command when confirmed.

Changes

Delete Focus from Tray Menu

Layer / File(s) Summary
Dependency
src-tauri/Cargo.toml
Adds tauri-plugin-dialog = "2" to dependencies.
Plugin Registration
src-tauri/src/app/mod.rs
Registers tauri_plugin_dialog::init() in the Tauri Builder plugin chain.
Menu Structure
src-tauri/src/app/tray.rs (build_menu)
Replaces disabled per-focus items with per-focus Submenu titled by focus.title; each submenu contains a Delete "{title}"… item with id tray-delete-{focus_id}.
Event Routing
src-tauri/src/app/tray.rs (setup, menu event handler)
Handles tray-quit; matches menu IDs with DELETE_PREFIX (tray-delete-), extracts focus id, and spawns a thread to call handle_delete.
Delete Handler
src-tauri/src/app/tray.rs (handle_delete)
New private helper: resolves focus title from CommandsState (fallback to id), shows blocking confirmation dialog (Delete Focus?) with custom buttons, and calls CommandsState.delete_focus(&focus_id) on confirmation; logs errors.

Sequence Diagram(s)

sequenceDiagram
    participant Tray as Tray Menu
    participant App as Main App (Tauri)
    participant Dialog as tauri_plugin_dialog
    participant Cmds as CommandsState
    Tray->>App: Menu event "tray-delete-{id}"
    App->>App: spawn thread -> call handle_delete(id)
    App->>Cmds: query focus title for {id}
    App->>Dialog: blocking confirm("Delete Focus?", message, buttons)
    Dialog-->>App: user confirms / cancels
    alt confirmed
        App->>Cmds: delete_focus(&id)
        Cmds-->>App: delete result (ok / err)
        App->>Tray: rebuild menu (focuses-changed triggered by watcher)
    else cancelled
        App-->>Tray: no action
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
A tiny menu with submenus bright,
I nudge "Delete…" and ask "Are you right?"
The dialog nods, the focus hops away,
A quieter tray to greet the day.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: 015 — delete focus from tray' directly and clearly summarizes the main objective of the changeset: adding the ability to delete a focus item from the tray menu.
Linked Issues check ✅ Passed The pull request implements all coding requirements from issue #8: adds tauri-plugin-dialog dependency, registers the plugin, replaces focus MenuItems with Submenus containing Delete items with encoded focus IDs, spawns a thread to show native confirmation dialog, and calls delete_focus on confirmation.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #8 requirements: Cargo.toml dependency addition, plugin registration, and tray menu refactoring for delete functionality are all in scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/015-delete-focus-tray

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src-tauri/src/app/tray.rs`:
- Around line 138-142: The call to state.0.delete_focus(&focus_id) currently
discards its Result; update the confirmed block so you capture the Result from
CommandsState::delete_focus and log or surface any Err (e.g., using the same
logging approach used in ui_bridge::delete_focus/inspect_err) so failures
(filesystem errors or not-found) are recorded; locate the call inside the if let
Some(state) = app.try_state::<crate::ui_bridge::CommandsState>() block and
replace the ignored let _ = ... with handling that logs the error (including
focus_id/context) instead of silently dropping it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5e6c1428-877f-4399-9d99-d7c1615ac6b4

📥 Commits

Reviewing files that changed from the base of the PR and between 14f42a1 and 3b65a7d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • src-tauri/Cargo.toml
  • src-tauri/src/app/mod.rs
  • src-tauri/src/app/tray.rs

Comment thread src-tauri/src/app/tray.rs
@archae0pteryx
archae0pteryx merged commit 2ea68b8 into main May 2, 2026
1 of 2 checks passed
@archae0pteryx
archae0pteryx deleted the feat/015-delete-focus-tray branch May 2, 2026 22:10
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.

015 — Delete Focus from tray

1 participant