Skip to content

feat(zsh): add lazy-load initialization APIs#131

Open
yuki-yano wants to merge 7 commits intomainfrom
feat/zsh-lazy-load-apis
Open

feat(zsh): add lazy-load initialization APIs#131
yuki-yano wants to merge 7 commits intomainfrom
feat/zsh-lazy-load-apis

Conversation

@yuki-yano
Copy link
Owner

@yuki-yano yuki-yano commented Mar 9, 2026

Summary

  • split zsh initialization into bootstrap and heavy init while keeping source zeno.zsh eager and backward-compatible
  • add upstream lazy-load APIs for widget registration, default key bindings, preload, and standard fallbacks
  • document eager/lazy usage and add shell tests covering eager load, lazy widget dispatch, fallbacks, and idempotent init

Testing

  • deno test --allow-run --allow-read --allow-write test/shell/*.ts
  • deno test --allow-run --allow-read --allow-write --allow-env --allow-ffi test/**/.ts test/.ts

Summary by CodeRabbit

  • New Features

    • Zsh lazy-loading for widgets and key bindings with preload/ensure-init and lazy-dispatch fallbacks.
    • Public utility to compute XDG config base directories for deterministic, deduplicated discovery.
    • New lightweight Zsh bootstrap entrypoint.
  • Documentation

    • README expanded with installation modes, lazy-load usage, public API, state variables, and fallback examples.
  • Bug Fixes

    • Prevent duplicate shell hook registrations; improved completion fallback behavior.
  • Tests

    • Extensive new tests for bootstrap, lazy API, preload, bindings, completion, and config discovery.

- split bootstrap and heavy init for zsh entrypoints
- add upstream lazy widget registration, fallback, and key binding APIs
- document lazy-load usage and cover eager/lazy flows with shell tests
Copilot AI review requested due to automatic review settings March 9, 2026 11:12
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

Adds a Zsh lazy-loading bootstrap and runtime: new bootstrap entrypoint, autoloadable init APIs (zeno-init, zeno-ensure-loaded, zeno-preload), lazy widget registration/dispatch/fallback, default keybinding helper, hook cleanup, XDG config discovery helpers, and extensive tests for init and lazy API behavior.

Changes

Cohort / File(s) Summary
Docs
README.md
Added lazy-loading documentation: default vs lazy install, bootstrap vs heavy init, public state variables and API surface, and widget fallback behaviors.
Bootstrap & Entrypoint
zeno-bootstrap.zsh, zeno.zsh
New bootstrap script sets ZENO_ROOT, PATH, fpath, autoloads and widget dirs; zeno.zsh now sources bootstrap and defers heavy init to zeno-init.
Zsh Init API
shells/zsh/functions/zeno-init, shells/zsh/functions/zeno-ensure-loaded, shells/zsh/functions/zeno-preload
Added autoloadable zeno-init (deno cache, version check, conditional socket enablement, hooks invocation, sets ZENO_LOADED), idempotent zeno-ensure-loaded, and zeno-preload shim.
Socket & Hooks
shells/zsh/functions/zeno-enable-sock
Silently removes existing precmd/chpwd/zshexit hooks before re-adding them to avoid duplicate registrations.
Lazy Widget Registration
shells/zsh/functions/zeno-register-lazy-widget, shells/zsh/functions/zeno-register-lazy-widgets
APIs to register single or multiple widgets for lazy loading; maintain ZENO_LAZY_WIDGETS and bind to dispatch handler with zle -N.
Lazy Dispatch & Fallbacks
shells/zsh/functions/zeno-lazy-widget-dispatch, shells/zsh/functions/zeno-run-lazy-fallback
Dispatches widget invocations through zeno-ensure-loaded; if not loaded or widget missing, runs fallbacks (completion, snippets, history selection, insert-space, etc.).
Default Key Bindings
shells/zsh/functions/zeno-bind-default-keys
New function binds default keys and supports --lazy to either register widgets lazily or eagerly load and bind them.
Zsh Widgets
shells/zsh/widgets/zeno-completion
Adjusted fallback lookup to consult the widgets table for fzf-completion fallback when appropriate.
Config loader & manager
src/config/loader.ts, src/config/manager.ts
Added appendUniqueDir and getXdgConfigBaseDirs; refactored findConfigFilePath to use base-dir helper; manager now aggregates XDG dirs via helper and includes XDG env inputs in cache signature.
Tests — zsh
test/shell/zsh_init_test.ts, test/shell/zsh_lazy_api_test.ts, test/shell/zsh_completion_widget_basic_test.ts, test/shell/zsh_test_utils.ts
Large test suites for bootstrap vs eager init, idempotency, wrapper-triggered loading, lazy registration/dispatch/fallbacks, default bindings in lazy/eager modes, completion fallback; added test entrypoint exports.
Tests — config
test/config/loader_test.ts, test/config/manager_multi_yaml_test.ts, test/config/manager_typescript_test.ts, test/settings_test.ts
Added tests for getXdgConfigBaseDirs ordering/deduplication, home-fallback discovery, multi-file YAML merging, and isolated env setups.

Sequence Diagrams

sequenceDiagram
    actor Shell
    participant zeno_zsh as "zeno.zsh"
    participant bootstrap as "zeno-bootstrap.zsh"
    participant zeno_init as "zeno-init"
    participant hooks as "zeno-enable-sock"
    Shell->>zeno_zsh: source zeno.zsh
    zeno_zsh->>bootstrap: source bootstrap
    bootstrap->>bootstrap: set PATH, fpath, autoloads, widget dirs
    bootstrap->>Shell: export ZENO_BOOTSTRAPPED=1
    alt heavy init requested
        Shell->>zeno_init: zeno-init / zeno-ensure-loaded
        zeno_init->>zeno_init: check ZENO_LOADED, run deno cache, detect deno version
        zeno_init->>hooks: zeno-enable-sock (register hooks)
        hooks->>hooks: add precmd/chpwd/zshexit hooks
        zeno_init->>Shell: export ZENO_LOADED=1
    end
Loading
sequenceDiagram
    actor User
    participant Key as "zle / Key"
    participant dispatcher as "zeno-lazy-widget-dispatch"
    participant ensure as "zeno-ensure-loaded"
    participant init as "zeno-init"
    participant widget as "Real Widget"
    participant fallback as "zeno-run-lazy-fallback"

    User->>Key: press key
    Key->>dispatcher: invoke widget (WIDGET)
    dispatcher->>ensure: call zeno-ensure-loaded
    alt not loaded
        ensure->>init: invoke zeno-init
        init->>ensure: return (ZENO_LOADED=1)
    else loaded
        ensure-->>dispatcher: return
    end
    alt widget defined
        dispatcher->>widget: call widget fn
        widget->>User: perform action
    else missing
        dispatcher->>fallback: call zeno-run-lazy-fallback
        fallback->>User: perform fallback action
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰
I nibbled the bootstrap at dawn's gentle light,
Deferred the heavy work until keys called me right.
When widgets wake, I hop quick and bright—
Lazy but ready, a playful little bite! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat(zsh): add lazy-load initialization APIs' directly summarizes the main change—introducing lazy-loading initialization APIs for Zsh.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/zsh-lazy-load-apis

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Zsh integration by introducing a lazy-loading mechanism. This change aims to improve shell startup performance by deferring the loading of heavier components until they are actually needed, while ensuring that existing eager loading configurations continue to function without modification. It provides new public APIs for users to explicitly opt into lazy-loading for various Zsh features, making the shell more responsive.

Highlights

  • Zsh Initialization Split: The Zsh initialization process has been split into a lightweight bootstrap phase and a heavier initialization phase. The existing source zeno.zsh command remains eager and backward-compatible, while zeno-bootstrap.zsh enables lazy loading.
  • Lazy-load APIs Introduced: New upstream APIs have been added for Zsh lazy-load, including functions for widget registration (zeno-register-lazy-widget, zeno-register-lazy-widgets), default key bindings (zeno-bind-default-keys --lazy), and preloading (zeno-preload).
  • Documentation and Testing: Comprehensive documentation has been added to README.md explaining both eager and lazy usage. New shell tests cover eager loading, lazy widget dispatch, fallback mechanisms, and idempotent initialization.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.md
    • Updated documentation to include instructions and details for Zsh lazy-load APIs.
    • Added examples for lazy-load setup, including custom key binds and default key bindings.
  • shells/zsh/functions/zeno-bind-default-keys
    • Added a new function to bind default Zsh key sequences, supporting both eager and lazy initialization modes.
  • shells/zsh/functions/zeno-enable-sock
    • Modified to explicitly remove existing zsh hooks before adding them, ensuring idempotency and preventing duplicate hook registrations.
  • shells/zsh/functions/zeno-ensure-loaded
    • Added a new function to check if the heavy initialization has occurred and trigger zeno-init if not, ensuring components are loaded when first accessed.
  • shells/zsh/functions/zeno-init
    • Added a new function encapsulating the 'heavy' initialization logic, including Deno cache, socket setup, history hooks, and preprompt hooks.
  • shells/zsh/functions/zeno-lazy-widget-dispatch
    • Added a new function to act as a dispatcher for lazily loaded widgets, ensuring zeno-init is called before the actual widget and providing fallbacks.
  • shells/zsh/functions/zeno-preload
    • Added a new function that serves as a public alias for zeno-ensure-loaded, allowing explicit preloading of Zeno components.
  • shells/zsh/functions/zeno-register-lazy-widget
    • Added a new function to register a single Zsh widget for lazy loading, associating it with the zeno-lazy-widget-dispatch handler.
  • shells/zsh/functions/zeno-register-lazy-widgets
    • Added a new function to register multiple Zsh widgets for lazy loading by iterating and calling zeno-register-lazy-widget.
  • shells/zsh/functions/zeno-run-lazy-fallback
    • Added a new function to provide specific fallback behaviors for various Zeno widgets when lazy initialization fails or is not yet complete.
  • test/shell/zsh_init_test.ts
    • Added new test cases to verify the behavior of Zsh initialization entrypoints, covering eager loading, deferred heavy initialization, and idempotency.
  • test/shell/zsh_lazy_api_test.ts
    • Added new test cases to validate the functionality of Zsh lazy-load APIs, including widget registration, fallback mechanisms, and lazy default key bindings.
  • test/shell/zsh_test_utils.ts
    • Updated to export REPO_ROOT and define constants for Zsh entrypoint scripts (ZSH_ENTRYPOINT, ZSH_BOOTSTRAP_ENTRYPOINT).
  • zeno-bootstrap.zsh
    • Added a new Zsh script that performs the minimal, essential bootstrap initialization, setting up paths and autoloading functions/widgets.
  • zeno.zsh
    • Refactored to source zeno-bootstrap.zsh and then conditionally call zeno-init, maintaining backward compatibility for eager loading.
Activity
  • The pull request description includes a 'Summary' of the changes and a 'Testing' section detailing the commands used to verify the changes. No human comments or reviews have been provided yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

- apply deno fmt output for new zsh lazy-load tests
- align local branch with CI fmt-check expectations
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant feature: lazy-loading for zsh initialization. This is a great improvement for startup performance. The implementation is well-structured, splitting the initialization into a lightweight bootstrap and a heavy, on-demand init. The new APIs for lazy widget registration and key binding are clear and well-documented in the README.

I've found a few issues:

  • A couple of correctness bugs in the lazy-loading fallback logic and Deno version parsing. These could cause errors in specific scenarios.
  • A minor maintainability issue with some redundant code in a fallback implementation.

Overall, this is a solid contribution. Addressing the feedback will make the new lazy-loading feature more robust.

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 a Zsh “bootstrap vs heavy init” split to support lazy-loading while keeping source zeno.zsh eager and backward-compatible, and introduces public lazy-load APIs with shell-level test coverage.

Changes:

  • Add zeno-bootstrap.zsh and new public Zsh APIs (zeno-init, zeno-ensure-loaded, zeno-preload, lazy widget registration, default key binding helper).
  • Update zeno.zsh to source the bootstrap and run eager initialization via zeno-init.
  • Add Deno-driven shell tests for eager init, lazy widget dispatch, fallbacks, and idempotency; document eager vs lazy usage in README.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
zeno.zsh Switches the main entrypoint to source the new bootstrap + invoke eager init.
zeno-bootstrap.zsh New lightweight bootstrap that sets ZENO_ROOT, updates path/fpath, and registers widgets without heavy initialization.
shells/zsh/functions/zeno-init New heavy initialization entrypoint (cache, sock, hooks, sets ZENO_LOADED).
shells/zsh/functions/zeno-ensure-loaded New helper to ensure heavy init is done (idempotent).
shells/zsh/functions/zeno-preload New public alias for preloading (zeno-ensure-loaded).
shells/zsh/functions/zeno-register-lazy-widget New API to register a widget as lazy-dispatched.
shells/zsh/functions/zeno-register-lazy-widgets New batch API for lazy widget registration.
shells/zsh/functions/zeno-lazy-widget-dispatch New dispatcher that ensures load before calling the real widget and falls back on failure.
shells/zsh/functions/zeno-run-lazy-fallback New upstream fallback behavior for common widgets when lazy load fails.
shells/zsh/functions/zeno-bind-default-keys New upstream helper to bind default keys in eager or lazy mode.
shells/zsh/functions/zeno-enable-sock Makes hook registration idempotent by removing existing hooks before adding them.
test/shell/zsh_test_utils.ts Exposes additional paths for shell tests (repo root / entrypoints).
test/shell/zsh_lazy_api_test.ts Adds tests validating lazy APIs, dispatch behavior, fallbacks, and key binding helper.
test/shell/zsh_init_test.ts Adds tests for eager entrypoint parity, bootstrap deferral, wrapper-init, and idempotency.
README.md Documents eager vs lazy usage and the new public APIs/state variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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: 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 `@shells/zsh/functions/zeno-bind-default-keys`:
- Around line 31-39: The lazy and eager branches ignore failures when
registering widgets; change zeno-bind-default-keys so that after calling
zeno-register-lazy-widgets it checks the return status and returns immediately
on non-zero, and in the eager branch check the exit status of each zle -N call
inside the for loop and return immediately (or propagate the error) if any zle
-N fails, before proceeding to bindkey; reference zeno-register-lazy-widgets,
zeno-register-lazy-widget, zeno-ensure-loaded, and the zle -N invocations to
locate and guard the failing calls.

In `@shells/zsh/functions/zeno-init`:
- Around line 15-37: The init function unconditionally exports ZENO_LOADED=1
even if earlier steps fail; update the failing steps—specifically the deno cache
invocation, the zeno-enable-sock call inside the deno_version branch, and the
zeno-history-hooks and zeno-preprompt-hooks invocations—to propagate errors back
to the caller by appending a short-circuit return (e.g., use "|| return $?" or
equivalent) so that any failure prevents exporting ZENO_LOADED and stops
initialization.

In `@shells/zsh/functions/zeno-run-lazy-fallback`:
- Around line 10-12: The current fallback selects fzf-completion based on
functions[fzf-completion], but zle requires a registered widget; update the
selection in zeno-run-lazy-fallback (and the same pattern in
shells/zsh/widgets/zeno-completion) to check the $widgets array for
'fzf-completion' (or use the existing ZENO_COMPLETION_FALLBACK override) before
assigning fallback_widget, and if it is not present fall back to
'expand-or-complete'; then call zle "$fallback_widget" as before so an
unregistered function won’t cause zle to error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: efe429b0-1113-4a53-ba71-fb3537d6b400

📥 Commits

Reviewing files that changed from the base of the PR and between 37bebf0 and 1054d73.

📒 Files selected for processing (15)
  • README.md
  • shells/zsh/functions/zeno-bind-default-keys
  • shells/zsh/functions/zeno-enable-sock
  • shells/zsh/functions/zeno-ensure-loaded
  • shells/zsh/functions/zeno-init
  • shells/zsh/functions/zeno-lazy-widget-dispatch
  • shells/zsh/functions/zeno-preload
  • shells/zsh/functions/zeno-register-lazy-widget
  • shells/zsh/functions/zeno-register-lazy-widgets
  • shells/zsh/functions/zeno-run-lazy-fallback
  • test/shell/zsh_init_test.ts
  • test/shell/zsh_lazy_api_test.ts
  • test/shell/zsh_test_utils.ts
  • zeno-bootstrap.zsh
  • zeno.zsh

- resolve ZENO_ROOT from the bootstrap file path
- fail fast when required zsh asset directories are missing
- add regression tests for wrapper sourcing and invalid roots
- add ~/.config as the first XDG config base when XDG_CONFIG_HOME is empty
- reuse the same XDG base resolution in config path lookup and config manager
- add regression tests for ~/.config discovery and isolate config tests from host env
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: 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/config/loader.ts`:
- Around line 59-68: The code treats an untrimmed whitespace-only
XDG_CONFIG_HOME as set, skipping the fallback; fix by trimming the
environment/param value before the presence check and before passing into
appendUniqueDir: read the raw value (params?.xdgConfigHome ??
Deno.env.get("XDG_CONFIG_HOME")), compute a trimmedXdg = raw?.trim() ||
undefined, use trimmedXdg in the ternary that sets fallbackConfigHome and in the
later appendUniqueDir call(s), ensuring xdgConfigHome/fallbackConfigHome are
based on trimmed input.

In `@src/config/manager.ts`:
- Around line 493-501: The cache key for settings omits XDG environment
variables, causing stale results when XDG_CONFIG_HOME or XDG_CONFIG_DIRS change;
update the settings cache signature (where getSettings() builds its cache key)
to also include Deno.env.get("XDG_CONFIG_HOME") and
Deno.env.get("XDG_CONFIG_DIRS") (or their parsed/normalized equivalents
returned/used by getXdgConfigBaseDirs/parseXdgConfigDirs) so that changes to
those variables invalidate the cache and new config locations are discovered.

In `@test/shell/zsh_init_test.ts`:
- Around line 258-289: The test file formatting is out of sync; run the
formatter on the failing test (the "source zeno-bootstrap.zsh fails fast when
ZENO_ROOT does not contain zsh assets" test) to fix the spacing/indentation
around the block that builds the script with runZshScriptRaw, shellQuote and
ZSH_BOOTSTRAP_ENTRYPOINT; run the repository formatter (deno fmt) targeting
test/shell/zsh_init_test.ts (or the whole repo) and re-run CI to ensure no
remaining formatting diffs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 409eda14-4877-4481-9f0b-fc547aadba23

📥 Commits

Reviewing files that changed from the base of the PR and between 1054d73 and 048cffe.

📒 Files selected for processing (9)
  • src/config/loader.ts
  • src/config/manager.ts
  • test/config/loader_test.ts
  • test/config/manager_multi_yaml_test.ts
  • test/config/manager_typescript_test.ts
  • test/settings_test.ts
  • test/shell/zsh_init_test.ts
  • test/shell/zsh_test_utils.ts
  • zeno-bootstrap.zsh
🚧 Files skipped from review as they are similar to previous changes (1)
  • zeno-bootstrap.zsh

- propagate lazy init and widget registration failures
- fix XDG config env handling and cache invalidation
- add regression coverage for review findings
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: 2

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

Inline comments:
In `@shells/zsh/functions/zeno-bind-default-keys`:
- Around line 21-50: The lazy widget list omits zeno-insert-space and
zeno-toggle-auto-snippet so in --lazy mode those keys are bound without
dispatcher handlers; update the lazy_widgets array to include
"zeno-insert-space" and "zeno-toggle-auto-snippet" (or remove their bindkey
calls in lazy mode), and ensure zeno-run-lazy-fallback has a fallback entry for
zeno-toggle-auto-snippet if you keep lazy binding; locate the array named
lazy_widgets and the registration call zeno-register-lazy-widgets to make the
change so both widgets are registered by the lazy dispatcher.

In `@src/config/loader.ts`:
- Around line 38-48: The function appendUniqueDir currently only trims input
which allows semantically identical paths like "/etc/xdg" and "/etc/xdg/" to be
considered different; update appendUniqueDir to canonicalize the dir before
deduplicating by using path normalization/resolution (e.g., call path.normalize
or path.resolve on dir after trimming and remove any trailing path separators)
so the normalized value is what you check against seen, add to seen, and push
onto target; update callers such as getXdgConfigBaseDirs() to rely on this
canonicalized behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df23a27a-c6b7-4337-b1b7-a338ca1068a4

📥 Commits

Reviewing files that changed from the base of the PR and between 048cffe and c22e8a6.

📒 Files selected for processing (12)
  • shells/zsh/functions/zeno-bind-default-keys
  • shells/zsh/functions/zeno-init
  • shells/zsh/functions/zeno-run-lazy-fallback
  • shells/zsh/widgets/zeno-completion
  • src/config/loader.ts
  • src/config/manager.ts
  • test/config/loader_test.ts
  • test/settings_test.ts
  • test/shell/zsh_completion_widget_basic_test.ts
  • test/shell/zsh_init_test.ts
  • test/shell/zsh_lazy_api_test.ts
  • zeno.zsh
🚧 Files skipped from review as they are similar to previous changes (4)
  • shells/zsh/functions/zeno-run-lazy-fallback
  • test/config/loader_test.ts
  • src/config/manager.ts
  • test/settings_test.ts

- assert zeno-insert-space and zeno-toggle-auto-snippet stay usable in lazy mode
- verify those lightweight widgets do not trigger heavy initialization
- canonicalize trailing separators before deduplicating config roots
- add regression coverage for slash-suffixed XDG directories
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.

🧹 Nitpick comments (1)
test/shell/zsh_lazy_api_test.ts (1)

254-256: Consider named assertions instead of hardcoded indices.

The array indices [1], [3], [10] assume a specific binding order. If the implementation changes the order of bindkey calls, these tests will break silently or produce confusing failures.

A more robust approach could search the log array for expected patterns:

# Example: Find binding containing "zeno-auto-snippet"
for entry in "${ZENO_TEST_BINDKEY_LOG[@]}"; do
  [[ "$entry" == *"zeno-auto-snippet"* ]] && print -r -- "$entry"
done

This is a minor concern since the current approach does validate the expected behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/shell/zsh_lazy_api_test.ts` around lines 254 - 256, The test currently
asserts bindkey outputs by indexing into ZENO_TEST_BINDKEY_LOG (e.g.
ZENO_TEST_BINDKEY_LOG[1], [3], [10]) which is brittle; change the assertions to
search ZENO_TEST_BINDKEY_LOG for entries matching the expected patterns instead
of fixed indices—iterate over "${ZENO_TEST_BINDKEY_LOG[@]}" and check each entry
for the expected key/value (use pattern matches for strings used by
zeno-test-print-kv) and assert presence; update the assertions that reference
ZENO_TEST_BINDKEY_LOG and zeno-test-print-kv so they verify existence of a
matching entry rather than relying on a specific array index.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/shell/zsh_lazy_api_test.ts`:
- Around line 254-256: The test currently asserts bindkey outputs by indexing
into ZENO_TEST_BINDKEY_LOG (e.g. ZENO_TEST_BINDKEY_LOG[1], [3], [10]) which is
brittle; change the assertions to search ZENO_TEST_BINDKEY_LOG for entries
matching the expected patterns instead of fixed indices—iterate over
"${ZENO_TEST_BINDKEY_LOG[@]}" and check each entry for the expected key/value
(use pattern matches for strings used by zeno-test-print-kv) and assert
presence; update the assertions that reference ZENO_TEST_BINDKEY_LOG and
zeno-test-print-kv so they verify existence of a matching entry rather than
relying on a specific array index.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f40c3b7-9d1a-4e6f-b7b9-8ce21b62470d

📥 Commits

Reviewing files that changed from the base of the PR and between c22e8a6 and d605fe1.

📒 Files selected for processing (3)
  • src/config/loader.ts
  • test/config/loader_test.ts
  • test/shell/zsh_lazy_api_test.ts

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