Skip to content
Open
33 changes: 33 additions & 0 deletions src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ fn main() {
{
ensure_sidecar_placeholder();
tauri_build::build();
// tauri-build embeds the comctl32-v6 SxS manifest (resource.lib) only
// into the binaries (`cargo:rustc-link-arg-bins`). Test binaries link
// the same lib, whose tauri code imports TaskDialogIndirect & friends
// — entry points that exist only in comctl32 v6. Without the manifest
// a test exe loads comctl32 v5 and dies at load with
// STATUS_ENTRYPOINT_NOT_FOUND (0xC0000139).
//
// Linking resource.lib into the tests cannot happen from here:
// `cargo:rustc-link-arg-tests` skips the lib's unit-test harness
// (it only reaches tests/*.rs), and the unspecific
// `cargo:rustc-link-arg` reaches the bins too, where the duplicate
// resources fail the link with CVT1100. The embedding therefore lives
// in lib.rs as a `#[cfg(test)] #[link(...)]`, which is scoped to the
// test compilations alone; this directive only makes resource.lib
// findable on the library search path.
//
// The target is read from Cargo's target env vars, not from
// `#[cfg(target_os = ...)]`: inside a build script, cfg describes the
// HOST, while these directives apply to the TARGET being built.
let windows_msvc = std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
&& std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc");
if windows_msvc {
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is always set");
println!("cargo:rustc-link-search=native={out_dir}");
// Integration tests (tests/*.rs) link the lib WITHOUT cfg(test), so
// the #[cfg(test)] #[link] in lib.rs is inert for them — their exes
// would load comctl32 v5 and die at load with
// STATUS_ENTRYPOINT_NOT_FOUND on TaskDialogIndirect. This directive
// reaches exactly those targets, complementing the lib-side
// attribute without ever hitting the same compilation twice.
let resource = std::path::Path::new(&out_dir).join("resource.lib");
println!("cargo:rustc-link-arg-tests={}", resource.display());
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions src-tauri/src/bin/codeg_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ async fn async_main() -> ExitCode {
));
let emitter = EventEmitter::web_only(broadcaster.clone(), acp_event_bus.clone());

// Push translation-settings changes to connected clients: hooks beyond
// the window that saved re-fetch their snapshot on this event instead of
// keeping the mount-time copy.
{
let emitter = emitter.clone();
codeg_lib::translation::settings::on_settings_change(Arc::new(move || {
codeg_lib::web::event_bridge::emit_event(
&emitter,
"translation-settings-changed",
serde_json::json!({}),
);
}));
}

// Build AppState
let pet_state_handle = codeg_lib::pet_state_mapper::new_pet_state_handle();
let connection_manager = codeg_lib::app_state::default_connection_manager();
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub mod session_info;
pub mod system_settings;
pub mod terminal;
pub mod token_usage;
pub mod translation;
pub mod turn_window;
pub mod version_control;
#[cfg(feature = "tauri-runtime")]
Expand Down
Loading