Skip to content

Conversation

qnixsynapse
Copy link
Contributor

@qnixsynapse qnixsynapse commented Aug 7, 2025

Describe Your Changes

  • Remove the in‑process activeSessions map and its cleanup logic from the TypeScript side.
  • Introduce new Tauri commands in Rust:
    • get_random_port – picks an unused port using a seeded RNG and checks availability.
    • find_session_by_model – returns the SessionInfo for a given model ID.
    • get_loaded_models – returns a list of currently loaded model IDs.
  • Update the extension’s TypeScript code to use these commands via invoke:
    • findSessionByModel, load, unload, chat, getLoadedModels, and embed now operate asynchronously and query the backend.
    • Remove the old is_port_available command and the custom port‑checking loop.
    • Simplify onUnload – session termination is now handled by the backend.
  • Drop unused helpers (sleep, waitForModelLoad) and related port‑availability code.
  • Add missing Rust imports (rand::{StdRng,Rng,SeedableRng}, HashSet) and improve error handling.
  • Register the new commands in src-tauri/src/lib.rs (replace is_port_available with the three new commands).

This refactor centralises session state and port allocation in the Rust backend, eliminates duplicated logic, and resolves race conditions around model loading and session cleanup.

Fixes Issues

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

Important

Refactor session management and port allocation to Rust backend, removing TypeScript activeSessions map and adding new Tauri commands.

  • Behavior:
    • Remove activeSessions map and cleanup logic from TypeScript in index.ts.
    • Add Tauri commands in Rust: get_random_port, find_session_by_model, get_loaded_models in server.rs.
    • Update TypeScript to use new commands via invoke: findSessionByModel, load, unload, chat, getLoadedModels, embed.
    • Remove is_port_available command and custom port-checking loop.
    • Simplify onUnload in index.ts to let backend handle session termination.
  • Code Cleanup:
    • Drop unused helpers sleep, waitForModelLoad in index.ts.
    • Add missing Rust imports and improve error handling in server.rs.
  • Command Registration:
    • Register new commands in lib.rs, replacing is_port_available with new commands.

This description was created by Ellipsis for daa6743. You can customize this summary. It will automatically update as commits are pushed.

- Remove the in‑process `activeSessions` map and its cleanup logic from the TypeScript side.
- Introduce new Tauri commands in Rust:
  - `get_random_port` – picks an unused port using a seeded RNG and checks availability.
  - `find_session_by_model` – returns the `SessionInfo` for a given model ID.
  - `get_loaded_models` – returns a list of currently loaded model IDs.
- Update the extension’s TypeScript code to use these commands via `invoke`:
  - `findSessionByModel`, `load`, `unload`, `chat`, `getLoadedModels`, and `embed` now operate asynchronously and query the backend.
  - Remove the old `is_port_available` command and the custom port‑checking loop.
  - Simplify `onUnload` – session termination is now handled by the backend.
- Drop unused helpers (`sleep`, `waitForModelLoad`) and related port‑availability code.
- Add missing Rust imports (`rand::{StdRng,Rng,SeedableRng}`, `HashSet`) and improve error handling.
- Register the new commands in `src-tauri/src/lib.rs` (replace `is_port_available` with the three new commands).

This refactor centralises session state and port allocation in the Rust backend, eliminates duplicated logic, and resolves race conditions around model loading and session cleanup.
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to daa6743 in 2 minutes and 39 seconds. Click for details.
  • Reviewed 328 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. extensions/llamacpp-extension/src/index.ts:1459
  • Draft comment:
    The error message in the chat method says 'Model have crashed!'. Consider correcting the grammar to 'Model has crashed!' for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. src-tauri/src/core/utils/extensions/inference_llamacpp_extension/server.rs:202
  • Draft comment:
    The raw string literal used for trimming the UNC prefix (i.e. r"\?") may not be correctly formed. Consider using an alternative raw string syntax (for example, r#"\?"#) to ensure it parses correctly.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. src-tauri/src/lib.rs:95
  • Draft comment:
    The registration of the new Tauri commands (get_random_port, find_session_by_model, get_loaded_models) for session management and port allocation is correctly integrated.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_vfwiArnWUbUARC5q

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Aug 7, 2025

Barecheck - Code coverage report

Total: 33.17%

Your code coverage diff: -0.01% ▾

✅ All code changes are covered

Copy link
Contributor

@louis-menlo louis-menlo left a comment

Choose a reason for hiding this comment

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

Works great & LGTM.

@qnixsynapse qnixsynapse merged commit 6a699d8 into dev Aug 7, 2025
16 checks passed
@qnixsynapse qnixsynapse deleted the fix/6082 branch August 7, 2025 07:36
@github-project-automation github-project-automation bot moved this to QA in Jan Aug 7, 2025
@github-actions github-actions bot added this to the v0.6.8 milestone Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

bug: FE doesn't save states on hot reload
2 participants