-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor: move session management & port allocation to backend #6083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
There was a problem hiding this 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 in3
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%
<= threshold50%
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%
<= threshold50%
None
Workflow ID: wflow_vfwiArnWUbUARC5q
You can customize 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>
Barecheck - Code coverage reportTotal: 33.17%Your code coverage diff: -0.01% ▾ ✅ All code changes are covered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great & LGTM.
Describe Your Changes
activeSessions
map and its cleanup logic from the TypeScript side.get_random_port
– picks an unused port using a seeded RNG and checks availability.find_session_by_model
– returns theSessionInfo
for a given model ID.get_loaded_models
– returns a list of currently loaded model IDs.invoke
:findSessionByModel
,load
,unload
,chat
,getLoadedModels
, andembed
now operate asynchronously and query the backend.is_port_available
command and the custom port‑checking loop.onUnload
– session termination is now handled by the backend.sleep
,waitForModelLoad
) and related port‑availability code.rand::{StdRng,Rng,SeedableRng}
,HashSet
) and improve error handling.src-tauri/src/lib.rs
(replaceis_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
Important
Refactor session management and port allocation to Rust backend, removing TypeScript
activeSessions
map and adding new Tauri commands.activeSessions
map and cleanup logic from TypeScript inindex.ts
.get_random_port
,find_session_by_model
,get_loaded_models
inserver.rs
.invoke
:findSessionByModel
,load
,unload
,chat
,getLoadedModels
,embed
.is_port_available
command and custom port-checking loop.onUnload
inindex.ts
to let backend handle session termination.sleep
,waitForModelLoad
inindex.ts
.server.rs
.lib.rs
, replacingis_port_available
with new commands.This description was created by
for daa6743. You can customize this summary. It will automatically update as commits are pushed.