Skip to content

Commit bb47889

Browse files
Copilotyiwang
andcommitted
Address code review feedback - fix UTF-8 truncation, improve readability, and portable shebang
Co-authored-by: yiwang <142937+yiwang@users.noreply.github.com>
1 parent 89ec147 commit bb47889

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

build-egui-web.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Build script for LocalGPT egui web UI
33
#
44
# This script compiles the server crate to WASM and generates the necessary

crates/server/src/web/app.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ impl eframe::App for WebApp {
6565
}
6666

6767
if let Some(ref id) = self.session_id {
68-
ui.label(format!("Session: {}...", &id[..8.min(id.len())]));
68+
// Safe truncation that respects UTF-8 character boundaries
69+
let truncated: String = id.chars().take(8).collect();
70+
ui.label(format!("Session: {}...", truncated));
6971
}
7072
});
7173
});
@@ -105,7 +107,10 @@ impl eframe::App for WebApp {
105107
.hint_text("Type a message..."),
106108
);
107109

108-
if ui.button("Send").clicked() || (input_response.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter) && !i.modifiers.shift)) {
110+
let enter_without_shift = input_response.has_focus()
111+
&& ui.input(|i| i.key_pressed(egui::Key::Enter) && !i.modifiers.shift);
112+
113+
if ui.button("Send").clicked() || enter_without_shift {
109114
self.send_message();
110115
input_response.request_focus();
111116
}

0 commit comments

Comments
 (0)