feat: 014 — new focus from tray - #12
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
📝 WalkthroughWalkthroughAdds a dedicated "New Focus" Tauri webview and UI, a tray menu item to open it, a React entry point and hook for the form, and build/config updates to include the new HTML entry. The window is hidden by default and shown/focused from the tray. ChangesNew Focus Window Feature
Sequence DiagramsequenceDiagram
actor User
participant Tray as Tray Menu
participant Backend as Tauri Backend
participant Window as New Focus Webview
participant UI as NewFocusWindow (React)
participant Cmd as create_focus Command
User->>Tray: Click "+ New Focus"
Tray->>Backend: emit menu event NEW_FOCUS_ID
Backend->>Window: show() and set_focus()
Window->>UI: mount / render form
User->>UI: enter title & description
User->>UI: submit
UI->>UI: validate title non-empty
alt valid
UI->>Cmd: invoke("create_focus",{title,description})
Cmd->>Backend: create focus
Cmd-->>UI: success
UI->>Window: hide()
else invalid
UI->>UI: set error state
end
alt cancel or Escape
User->>UI: cancel / press Escape
UI->>Window: hide()
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 8/10 reviews remaining, refill in 9 minutes and 19 seconds. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/components/NewFocusWindow.tsx`:
- Around line 1-82: NewFocusWindow currently performs Tauri I/O and window
lifecycle (invoke, getCurrentWindow, hideWindow, useEffect keyboard handler and
handleSubmit), which violates the view-only components rule; refactor by moving
all Tauri calls and stateful lifecycle into src/new-focus.tsx (or a new hook
useNewFocusWindow) and keep NewFocusWindow purely presentational: remove invoke,
getCurrentWindow, hideWindow, useEffect, handleSubmit and instead accept props
like title, description, setTitle, setDescription, submitting, error, onSubmit,
and onCancel (or an onCreate callback receiving {title,description} and an
onHide/onCancel callback) so the parent/hook handles create_focus invocation and
window hide/show logic and passes callbacks into the NewFocusWindow component.
- Around line 35-38: The code in NewFocusWindow.tsx currently sends description:
description.trim() || null to the invoke("create_focus", ...) call which
serializes null and breaks Rust deserialization for CreateFocusInput (expects a
String with serde(default)); change the payload to send an empty string instead
by removing the "|| null" so description is always a string (use
description.trim() only) when calling invoke("create_focus", ...).
In `@vite.config.ts`:
- Around line 12-19: The Vite ESM config currently uses __dirname in
build.rollupOptions.input (where resolve(..., "index.html") and resolve(...,
"new-focus.html") are called) but __dirname is not defined in ESM; add an
ESM-safe directory helper at the top of the config using import.meta.url and
fileURLToPath to derive a dirname (or compute a baseDir via
path.dirname(fileURLToPath(import.meta.url))), then use that derived dirname
when calling resolve for the "index.html" and "new-focus.html" entries so the
paths resolve correctly in ESM.
🪄 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: 2ea711e4-1fd5-4636-9798-43fe0ce032a2
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (8)
new-focus.htmlpackage.jsonsrc-tauri/capabilities/default.jsonsrc-tauri/src/app/tray.rssrc-tauri/tauri.conf.jsonsrc/components/NewFocusWindow.tsxsrc/new-focus.tsxvite.config.ts
Add "+ New Focus" tray menu item that opens a small dedicated webview window (320×180, no decorations, transparent). Clicking the item shows and focuses the window; a second click brings it to front without creating a duplicate. Submitting creates the focus via create_focus and hides the window; Escape/Cancel also hides. - new-focus.html + src/new-focus.tsx: separate entry point so the main overlay bundle stays lean - NewFocusWindow: always-visible form, resets on submit/cancel - vite multi-page build via rollupOptions.input - @types/node added for path.resolve in vite config - capabilities/default.json: new-focus window added to windows list
- vite.config.ts: use fileURLToPath(import.meta.url) for ESM-safe __dirname - NewFocusWindow: extract Tauri I/O into useNewFocusWindow hook; component is now purely presentational (props-only, no invoke/window calls) - new-focus.tsx: wire useNewFocusWindow hook + NewFocusWindow component - description sent as empty string (not null) via focusWriter.createFocus
a4463b6 to
b871032
Compare
Summary
new-focusWebviewWindow (decorations: false,transparent: true,visible: falseat launch)create_focusTauri command; window hides on successImplementation notes
new-focus.html/src/new-focus.tsx— separate Vite entry point so main overlay bundle stays leanNewFocusWindow— always-visible form (no toggle button), resets state on submit/cancelrollupOptions.inputfor multi-page production build@types/nodeadded (devDep) forpath.resolvein vite configcapabilities/default.json:new-focuswindow added to windows listTest plan
task checkgreen (CI)Closes #7
Summary by CodeRabbit
New Features
Chores
Dependencies