Skip to content

Commit 4264586

Browse files
committed
fix: only track OpenCode config paths for restart notice
1 parent e250832 commit 4264586

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

src-tauri/src/backend/app_server.rs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,45 @@ async fn latest_change_under_dir(root: &Path) -> Option<chrono::DateTime<chrono:
187187
latest
188188
}
189189

190+
async fn latest_change_in_tracked_config_paths(
191+
config_root: &Path,
192+
) -> Option<chrono::DateTime<chrono::Utc>> {
193+
let tracked_paths = [
194+
config_root.join("opencode.jsonc"),
195+
config_root.join("command"),
196+
config_root.join("agent"),
197+
config_root.join("skill"),
198+
];
199+
200+
let mut latest = None;
201+
202+
for tracked_path in tracked_paths {
203+
let metadata = match tokio::fs::metadata(&tracked_path).await {
204+
Ok(metadata) => metadata,
205+
Err(_) => continue,
206+
};
207+
208+
if let Ok(modified) = metadata.modified() {
209+
let modified_at = chrono::DateTime::<chrono::Utc>::from(modified);
210+
latest = Some(match latest {
211+
Some(current) if current >= modified_at => current,
212+
_ => modified_at,
213+
});
214+
}
215+
216+
if metadata.is_dir() {
217+
if let Some(dir_latest) = latest_change_under_dir(&tracked_path).await {
218+
latest = Some(match latest {
219+
Some(current) if current >= dir_latest => current,
220+
_ => dir_latest,
221+
});
222+
}
223+
}
224+
}
225+
226+
latest
227+
}
228+
190229
pub(crate) async fn opencode_restart_required_status() -> Value {
191230
let Some(config_root) = crate::codex::home::resolve_default_codex_home() else {
192231
return json!({
@@ -237,7 +276,7 @@ pub(crate) async fn opencode_restart_required_status() -> Value {
237276
});
238277
};
239278

240-
let latest_change = latest_change_under_dir(&config_root).await;
279+
let latest_change = latest_change_in_tracked_config_paths(&config_root).await;
241280
let required = latest_change
242281
.map(|changed_at| changed_at > server_started_at)
243282
.unwrap_or(false);
@@ -251,7 +290,7 @@ pub(crate) async fn opencode_restart_required_status() -> Value {
251290
"serverStartedAt": server_started_at.to_rfc3339(),
252291
"latestConfigChangeAt": latest_change.map(|dt| dt.to_rfc3339()),
253292
"reason": if required {
254-
Some("Config changed since server start")
293+
Some("OpenCode config changed since server start")
255294
} else {
256295
None::<&str>
257296
}

src/features/app/components/SidebarCornerActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function SidebarCornerActions({
107107
const reasonText = restartNotice.reason?.trim().replace(/[.\s]+$/, "") ?? "";
108108
const restartTooltip = reasonText
109109
? `${reasonText}. Restart OpenCode to refresh agents and models.`
110-
: "Config changed. Restart OpenCode to refresh agents and models.";
110+
: "OpenCode config changed. Restart OpenCode to refresh agents and models.";
111111

112112
return (
113113
<div className="sidebar-corner-actions">

0 commit comments

Comments
 (0)