Skip to content

Commit a9f9546

Browse files
committed
fix(tauri): correct agent_skills dedup sort and release SESSIONS during pty_write
Sort by (name, kind, source) so dedup_by on (name, kind) sees adjacent duplicates. Clone the session writer Arc under SESSIONS then perform I/O under only the per-session writer lock.
1 parent 95a9bb2 commit a9f9546

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • native/macos/comux-tauri/src-tauri/src

native/macos/comux-tauri/src-tauri/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,14 @@ fn pty_start(app: AppHandle, options: StartOptions) -> Result<(), String> {
190190

191191
#[tauri::command]
192192
fn pty_write(thread_id: String, bytes: Vec<u8>) -> Result<(), String> {
193-
let guard = SESSIONS.lock();
194-
let session = guard
195-
.get(&thread_id)
196-
.ok_or_else(|| format!("thread '{}' not found", thread_id))?;
197-
let mut writer = session.writer.lock();
193+
let writer = {
194+
let guard = SESSIONS.lock();
195+
let session = guard
196+
.get(&thread_id)
197+
.ok_or_else(|| format!("thread '{}' not found", thread_id))?;
198+
Arc::clone(&session.writer)
199+
};
200+
let mut writer = writer.lock();
198201
writer.write_all(&bytes).map_err(|e| e.to_string())?;
199202
writer.flush().map_err(|e| e.to_string())?;
200203
Ok(())
@@ -503,7 +506,7 @@ fn agent_skills(harness: Option<String>, project_root: Option<String>) -> Vec<Ag
503506
}
504507
}
505508

506-
out.sort_by(|a, b| a.name.cmp(&b.name).then(a.source.cmp(&b.source)));
509+
out.sort_by(|a, b| a.name.cmp(&b.name).then(a.kind.cmp(&b.kind)).then(a.source.cmp(&b.source)));
507510
out.dedup_by(|a, b| a.name == b.name && a.kind == b.kind);
508511
out
509512
}

0 commit comments

Comments
 (0)