mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
feat(dev): run dev alongside release with shared app data (#866)
* feat(dev): run dev alongside release with shared app data Skip tauri-plugin-single-instance in debug builds so `tauri dev` can run while an installed release instance is open. Keep the same bundle identifier and data directory; label the dev window "Psysonic (Dev)". * fix(dev): gate on_second_instance behind release cfg Avoid dead_code warning in debug builds where single-instance is skipped. * feat(dev): red sidebar brand and monochrome titlebar chrome Tag the document in Vite dev and style the logo header with a red background plus gray window controls so dev is obvious at a glance. * feat(dev): skip OS hotkeys and add mobile DEV markers Debug builds no longer register global shortcuts, MPRIS, or Windows taskbar media controls so release keeps system input when both run. Flip the tray icon horizontally in dev and show a fixed DEV badge on narrow layouts. * docs(changelog): note PR #866 parallel dev alongside release * fix(dev): satisfy clippy needless_return in debug-only paths
This commit is contained in:
+40
-18
@@ -38,6 +38,28 @@ const MAX_DL_CONCURRENCY: usize = 4;
|
||||
/// `None` if souvlaki failed to initialize (e.g. no D-Bus session on Linux).
|
||||
type MprisControls = Mutex<Option<souvlaki::MediaControls>>;
|
||||
|
||||
/// Release builds only: focus or CLI-hand off when a second instance is launched.
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn on_second_instance<R: tauri::Runtime>(
|
||||
app: &tauri::AppHandle<R>,
|
||||
argv: Vec<String>,
|
||||
_cwd: String,
|
||||
) {
|
||||
if !crate::cli::handle_cli_on_primary_instance(app, &argv) {
|
||||
let window = app.get_webview_window("main").expect("no main window");
|
||||
// The window may have been hidden via the close-to-tray path,
|
||||
// which injects PAUSE_RENDERING_JS (sets `__psyHidden=true`,
|
||||
// pauses CSS animations). Tray-icon restore mirrors this with
|
||||
// RESUME_RENDERING_JS — second-launch restore must do the same,
|
||||
// otherwise the webview comes back with rendering still paused
|
||||
// and navigation looks blank (issue #497).
|
||||
let _ = window.eval(RESUME_RENDERING_JS);
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() {
|
||||
// Linux: second `psysonic --player …` forwards over D-Bus before heavy startup.
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -57,7 +79,7 @@ pub fn run() {
|
||||
|
||||
let (audio_engine, _audio_thread) = audio::create_engine();
|
||||
|
||||
tauri::Builder::default()
|
||||
let builder = tauri::Builder::default()
|
||||
.manage(audio_engine)
|
||||
.manage(ShortcutMap::default())
|
||||
.manage(discord::DiscordState::new())
|
||||
@@ -78,24 +100,18 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_store::Builder::default().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| {
|
||||
if !crate::cli::handle_cli_on_primary_instance(app, &argv) {
|
||||
let window = app.get_webview_window("main").expect("no main window");
|
||||
// The window may have been hidden via the close-to-tray path,
|
||||
// which injects PAUSE_RENDERING_JS (sets `__psyHidden=true`,
|
||||
// pauses CSS animations). Tray-icon restore mirrors this with
|
||||
// RESUME_RENDERING_JS — second-launch restore must do the same,
|
||||
// otherwise the webview comes back with rendering still paused
|
||||
// and navigation looks blank (issue #497).
|
||||
let _ = window.eval(RESUME_RENDERING_JS);
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}))
|
||||
.plugin(tauri_plugin_fs::init());
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
let builder = builder.plugin(tauri_plugin_single_instance::init(on_second_instance));
|
||||
|
||||
builder
|
||||
.setup(|app| {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.set_title("Psysonic (Dev)");
|
||||
}
|
||||
|
||||
// ── Analysis cache (SQLite) ───────────────────────────────────
|
||||
{
|
||||
let cache = analysis_cache::AnalysisCache::init(app.handle())
|
||||
@@ -386,6 +402,8 @@ pub fn run() {
|
||||
}
|
||||
|
||||
// ── MPRIS2 / OS media controls via souvlaki ──────────────────
|
||||
// Release only: debug builds share the D-Bus name / SMTC slot with prod.
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
use souvlaki::{MediaControlEvent, MediaControls, PlatformConfig};
|
||||
|
||||
@@ -474,9 +492,13 @@ pub fn run() {
|
||||
|
||||
app.manage(MprisControls::new(maybe_controls));
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
app.manage(MprisControls::new(None));
|
||||
}
|
||||
|
||||
// ── Windows Taskbar Thumbnail Toolbar ────────────────────────
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(all(target_os = "windows", not(debug_assertions)))]
|
||||
{
|
||||
use tauri::Manager;
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
|
||||
Reference in New Issue
Block a user