Skip to content

Commit d6bf486

Browse files
committed
refactor(host): split settings_io; keep touch_recent in op-host-desktop (Phase 4, Task 4.3)
The headless settings persistence (Fingerprint/fingerprint/save_if_changed/load/save + the on-disk *Payload DTOs, id allocators, detect_system_locale, enum<->str converters) + settings_io_tests move to op_web_daemon::settings_io. The host-coupled touch_recent (takes &mut WidgetHostNative — orphan rule) stays as the op-host-desktop residual. main.rs / app_handler / web_canvas_server load/save/fingerprint/save_if_changed refs repointed to op_web_daemon::; persistence keeps crate::settings_io::touch_recent. 11 settings_io tests green; no dep/lock change.
1 parent 775e32a commit d6bf486

8 files changed

Lines changed: 653 additions & 643 deletions

File tree

crates/op-host-desktop/src/app_handler.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use crate::{
55
a11y, chat_attachment, chat_session, codegen_session, cursor_icon, design_session,
6-
figma_import_session, frame, git_jobs, menu, persistence, settings_io, window_state,
6+
figma_import_session, frame, git_jobs, menu, persistence, window_state,
77
DesktopApp, DesktopEvent, INITIAL_VIEWPORT_H, INITIAL_VIEWPORT_W,
88
};
99
use op_host_native::{NativeBackend, ProviderError, SharedSkiaContext, SharedSkiaError};
@@ -281,7 +281,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
281281
// one-off `op start` never rewrites the user's saved settings.
282282
let bootstrap_changed = self.bootstrap_mcp_runtime_from_settings();
283283
if bootstrap_changed && self.force_live_mcp_port.is_none() {
284-
settings_io::save(self.host.editor_state());
284+
op_web_daemon::settings_io::save(self.host.editor_state());
285285
}
286286
// Publish (or clean up) the live MCP discovery file now that the
287287
// launch-time server state is settled, so `op` can find this canvas.
@@ -347,7 +347,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
347347
// on the trackpad hot path.
348348
let settings_before = match &event {
349349
WindowEvent::CursorMoved { .. } => None,
350-
_ => Some(settings_io::fingerprint(self.host.editor_state())),
350+
_ => Some(op_web_daemon::settings_io::fingerprint(self.host.editor_state())),
351351
};
352352
let mcp_cli_before = match &event {
353353
WindowEvent::CursorMoved { .. } => None,
@@ -361,7 +361,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
361361
// The unsaved-changes prompt can abort the close.
362362
if self.confirm_close() {
363363
self.host.flush_settings_input();
364-
settings_io::save(self.host.editor_state());
364+
op_web_daemon::settings_io::save(self.host.editor_state());
365365
event_loop.exit();
366366
}
367367
}
@@ -872,7 +872,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
872872
// — a bare `exit()` would drop work.
873873
if self.confirm_close() {
874874
self.host.flush_settings_input();
875-
settings_io::save(self.host.editor_state());
875+
op_web_daemon::settings_io::save(self.host.editor_state());
876876
event_loop.exit();
877877
}
878878
}
@@ -1219,7 +1219,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
12191219
self.request_redraw(true);
12201220
}
12211221
if let Some(before) = settings_before {
1222-
settings_io::save_if_changed(self.host.editor_state(), before);
1222+
op_web_daemon::settings_io::save_if_changed(self.host.editor_state(), before);
12231223
}
12241224
// A Git-panel click or Enter may have queued an action
12251225
// (Commit / Refresh / Pull) — run it after the event.
@@ -1246,7 +1246,7 @@ impl ApplicationHandler<DesktopEvent> for DesktopApp {
12461246
// `CloseRequested`; flush MCP port draft before snapshotting so
12471247
// a focused-but-uncommitted edit isn't silently dropped.
12481248
self.host.flush_settings_input();
1249-
settings_io::save(self.host.editor_state());
1249+
op_web_daemon::settings_io::save(self.host.editor_state());
12501250
if let Some(mut server) = self.mcp_server.take() {
12511251
server.stop();
12521252
crate::mcp_port_file::remove();

crates/op-host-desktop/src/kit_persistence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn kit_to_persisted(kit: &UIKit) -> PersistedKit {
146146
// ---------------------------------------------------------------------------
147147

148148
/// Hydrate imported kits + the browser-open flag onto a fresh
149-
/// `EditorState` (call once at startup, after `settings_io::load`).
149+
/// `EditorState` (call once at startup, after `op_web_daemon::settings_io::load`).
150150
/// Best-effort: a missing / unreadable / malformed file leaves the
151151
/// built-in kits alone.
152152
pub fn load(state: &mut EditorState) {

crates/op-host-desktop/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl DesktopApp {
265265
let mut host = WidgetHostNative::new();
266266
let fit_blank_frame = initial_file.is_none();
267267
// Best-effort prefs restore onto the host's `EditorState`.
268-
settings_io::load(host.editor_state_mut());
268+
op_web_daemon::settings_io::load(host.editor_state_mut());
269269
// Imported UIKits + browser-open flag (`uikits.json`). Skipped
270270
// under test like the update / model probes — unit tests must
271271
// not see a developer machine's kit store.

0 commit comments

Comments
 (0)