Skip to content

Conversation

@yujonglee
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Nov 19, 2025

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit 363160c
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/691da08b8ffd4e0008c05eec
😎 Deploy Preview https://deploy-preview-1733--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

📝 Walkthrough

Walkthrough

This PR refactors hook argument handling across the codebase, replacing the session_id parameter with resource_dir, app_hyprnote, and an optional app_meeting parameter. The changes span from desktop app listener integration and web documentation to Rust plugin event definitions and documentation extraction logic.

Changes

Cohort / File(s) Summary
Hook Argument Schema & Documentation
apps/web/content-collections.ts, apps/web/content/docs/hooks/beforeListeningStarted.mdx, apps/web/content/docs/hooks/afterListeningStopped.mdx
Added optional boolean field to hook argument schema. Updated hook documentation to replace session_id with resource-dir, app-hyprnote, and optional app-meeting arguments.
Rust Event Structures & CLI Generation
plugins/hooks/src/event.rs, plugins/hooks/src/naming.rs, plugins/hooks/src/lib.rs
Replaced session_id: String with resource_dir: String, app_hyprnote: String, and app_meeting: Option<String> in hook argument structs. Added cli_flag utility to convert snake_case to CLI flags. Updated to_cli_args implementations to use the new fields.
Hook Documentation Extraction
plugins/hooks/src/docs.rs
Refactored type information handling with new TypeInfo helper. Added support for parsing optional fields and extracting hook variants. Introduced utilities for AST navigation, type resolution, and field extraction. Extended ArgField with optional flag serialization.
Hook Configuration Documentation
plugins/hooks/src/config.rs
Updated documentation comments for HooksConfig and HookDefinition without functional changes.
Web Hooks List UI
apps/web/src/components/hooks-list.tsx
Redesigned argument rendering with two-column responsive grid layout. Added monospace badges for argument names, type information display, and optional indicators. Improved spacing and typography.
Desktop Listener Integration
apps/desktop/src/store/zustand/listener/general.ts
Modified hook listeners to asynchronously fetch app data directory and name via Tauri, then invoke hooks with resource_dir, app_hyprnote, and app_meeting parameters.

Sequence Diagram(s)

sequenceDiagram
    participant Desktop App
    participant Tauri
    participant Hook System
    participant Subprocess

    Desktop App->>Tauri: appDataDir()
    Tauri-->>Desktop App: data_dir
    Desktop App->>Tauri: getName()
    Tauri-->>Desktop App: app_name
    
    Desktop App->>Hook System: runEventHooks with resource_dir, app_hyprnote, app_meeting
    Hook System->>Hook System: Build CLI args via cli_flag()
    Hook System->>Subprocess: Execute with --resource-dir, --app-hyprnote, --app-meeting
    Subprocess-->>Hook System: Result
    Hook System-->>Desktop App: Completion
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Rust documentation extraction logic (docs.rs): The refactoring introduces new type information handling and AST traversal patterns that warrant careful review, particularly the optional field serialization and type resolution utilities.
  • Hook argument struct changes (event.rs): Verify that all CLI argument generation correctly maps the new fields and that the optional field is properly handled in both serialization and CLI construction.
  • Type safety: Ensure the changes to ArgField with the optional flag don't break existing serialization or cause runtime issues in documentation generation.
  • Web UI rendering (hooks-list.tsx): Confirm the responsive grid layout displays correctly across breakpoints and that optional field indicators are properly styled and accessible.

Possibly related PRs

  • fixes before beta release #1692: Refactors hook/resource path flow to use tauri-managed resource directories instead of session-based paths, directly related to the argument structure changes in this PR.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'change-hook-args' is vague and generic, using non-descriptive terms that don't convey the specific nature of the change beyond referencing hook arguments. Improve the title to be more specific, such as 'Replace session_id with resource_dir and app-specific arguments in hooks' or 'Update hook arguments to include resource directory and app metadata'.
Description check ❓ Inconclusive The pull request has no description provided, making it impossible to assess whether it explains the changeset adequately. Add a pull request description explaining the motivation, changes made, and impact of replacing session_id with resource_dir, app_hyprnote, and app_meeting arguments.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch change-hook-args-resource-dir

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.

@yujonglee yujonglee merged commit cfc41b2 into main Nov 19, 2025
8 of 10 checks passed
@yujonglee yujonglee deleted the change-hook-args-resource-dir branch November 19, 2025 10:50
Copy link

@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: 0

🧹 Nitpick comments (2)
apps/desktop/src/store/zustand/listener/general.ts (1)

207-222: Before-listening hook runs fire-and-forget; verify ordering expectations

The beforeListeningStarted hook is triggered via a Promise.all(...).then(...).catch(...) inside the Effect program but is not awaited, so:

  • the session start effect proceeds without waiting for the hook, and
  • hook failures are logged but do not affect start() outcome.

If hooks are meant to be advisory, this non-blocking pattern is fine. If you need strict “run hooks successfully before the session is considered started” semantics, consider awaiting runEventHooks (or integrating it into the Effect program) so failures can influence control flow when appropriate.

plugins/hooks/src/docs.rs (1)

310-382: Comprehensive type formatting with union support.

The refactored format_type correctly handles TypeScript's type system nuances:

  • Null/undefined detection for optional inference (lines 330-332)
  • Type deduplication (line 343)
  • Recursive union flattening

The union handling block (lines 323-359) is quite involved. If this function grows further, consider extracting it to format_union_type for readability.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6c6ea2 and 363160c.

⛔ Files ignored due to path filters (1)
  • plugins/hooks/js/bindings.gen.ts is excluded by !**/*.gen.ts
📒 Files selected for processing (10)
  • apps/desktop/src/store/zustand/listener/general.ts (3 hunks)
  • apps/web/content-collections.ts (1 hunks)
  • apps/web/content/docs/hooks/afterListeningStopped.mdx (1 hunks)
  • apps/web/content/docs/hooks/beforeListeningStarted.mdx (1 hunks)
  • apps/web/src/components/hooks-list.tsx (1 hunks)
  • plugins/hooks/src/config.rs (1 hunks)
  • plugins/hooks/src/docs.rs (5 hunks)
  • plugins/hooks/src/event.rs (2 hunks)
  • plugins/hooks/src/lib.rs (1 hunks)
  • plugins/hooks/src/naming.rs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
plugins/hooks/src/docs.rs (1)
plugins/hooks/src/naming.rs (1)
  • cli_flag (1-10)
plugins/hooks/src/event.rs (1)
plugins/hooks/src/naming.rs (1)
  • cli_flag (1-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Redirect rules - hyprnote
  • GitHub Check: Header rules - hyprnote
  • GitHub Check: Pages changed - hyprnote
  • GitHub Check: ci (macos, macos-14)
  • GitHub Check: fmt
🔇 Additional comments (16)
plugins/hooks/src/lib.rs (1)

1-7: New naming module is correctly wired into the crate

Declaring mod naming; here cleanly exposes the new helper module to the rest of the crate; no issues from a wiring/visibility standpoint.

plugins/hooks/src/config.rs (1)

5-20: Doc comment updates are accurate and helpful

The new comments for HooksConfig and HookDefinition.command correctly describe the existing fields and behavior without altering the API.

apps/web/content/docs/hooks/afterListeningStopped.mdx (1)

3-14: Hook docs align with new argument model

The updated description and the three arguments (--resource-dir, --app-hyprnote, optional --app-meeting) match the new hook payload shape and CLI flag naming; this keeps documentation in sync with the implementation.

apps/web/content/docs/hooks/beforeListeningStarted.mdx (1)

3-14: Consistent argument documentation for pre-listening hook

The front matter now correctly documents the same three arguments as the post-listening hook, with --app-meeting marked optional. This symmetry makes the before/after hooks easy to reason about.

plugins/hooks/src/naming.rs (1)

1-32: cli_flag helper and tests look correct and well-scoped

The implementation correctly maps snake_case field names to CLI flags (with -- prefix and _-), while leaving existing hyphens and empty strings handled as expected. The unit tests capture the intended behavior and key edge cases.

apps/web/content-collections.ts (1)

262-274: Hook argument schema extension is backwards compatible

Adding optional: z.boolean().default(false) to each argument keeps existing docs valid (they default to non-optional) while enabling explicit optional args like app-meeting. This aligns with the new UI rendering for optional arguments.

apps/desktop/src/store/zustand/listener/general.ts (2)

1-2: New imports are scoped to hook context only

Importing the app data directory and app name here is appropriate and keeps the hook-related logic self-contained; no conflicts with existing imports.


278-296: After-listening hook mirrors pre-listening behavior

The afterListeningStopped hook uses the same pattern and session-specific resource_dir construction as the pre-listening hook, which keeps behavior consistent. As above, it runs non-blocking and only logs failures; that’s reasonable if stop should not be gated on hooks.

apps/web/src/components/hooks-list.tsx (1)

12-71: Improved hook + argument layout cleanly surfaces optionality

The reworked layout (section borders, argument panel, two-column grid) makes hooks and their arguments much easier to scan. Using arg.optional to conditionally show an “optional” badge lines up with the updated content schema and MDX front matter.

plugins/hooks/src/docs.rs (4)

3-3: LGTM: Clean type refactoring.

The introduction of TypeInfo to bundle type name with optional status is a solid improvement over the previous approach. The is_false predicate for conditional serialization is idiomatic.

Also applies to: 33-35, 43-56, 384-386


93-143: LGTM: Hook event parsing is well-structured.

The refactored flow through exported_type_aliasesextract_fieldshook_variantshook_from_variant is clear and modular. The safe fallbacks (unwrap_or_default, unwrap_or) handle missing types gracefully.


145-176: LGTM: Field extraction properly handles optional detection.

The use of cli_flag at line 157 ensures documentation displays CLI-friendly names (e.g., --resource-dir), which improves user experience. The combined optional check at line 169 correctly captures both explicit ? markers and union-inferred nullability.


195-246: LGTM: AST navigation helpers are robust.

These helpers provide safe Option-based navigation through the TypeScript AST. The recursive unwrapping of parenthesized types in type_lit_from (line 234) is a nice touch.

plugins/hooks/src/event.rs (3)

1-1: LGTM: Helper function reduces duplication.

The push_cli_arg helper centralizes the flag-value pair logic and ensures consistent CLI flag formatting through cli_flag. Keeping it private is appropriate.

Also applies to: 32-35


38-61: LGTM: Argument structure and CLI conversion are correct.

The capacity hint of 6 at line 51 is optimal (3 fields × 2 elements each). The use of stringify! combined with cli_flag ensures compile-time field name safety with proper CLI formatting.

The conditional inclusion of app_meeting (lines 55-57) correctly handles the optional field.


64-87: LGTM: Struct duplication provides type safety.

While BeforeListeningStartedArgs and AfterListeningStoppedArgs are currently identical, maintaining separate types is sound for:

  • Semantic clarity (different lifecycle events)
  • Type safety (prevents argument confusion)
  • Future flexibility (events may diverge)

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