fix(app): what is left of the virtual monitor's driver stays ours and can be removed from the screen
- a failed install forgets the driver (registry value, settings folder) only when its clean-up left no device and no package, and never when it was ours before; otherwise it stays ours and the error gives both the install's reason and that something is left to remove - the driver status separates a usable monitor (installed) from what this app left without one (leftover) and names the button (action): uninstall for both, so a removal whose package step failed can be retried from the features screen - pure rules after_failed_install and driver_status with unit tests; checked again on the win-ci VM: a declined install leaves nothing, then install and uninstall Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -290,10 +290,14 @@ the browser runs headless with a note.
|
||||
device (`Root\MttVDD`, display class) and installs the driver; Windows then asks once whether to
|
||||
install software from the SignPath Foundation. The new monitor is taken off the desktop at once.
|
||||
A failed install, also the person answering no to that question ("취소했습니다"), undoes what
|
||||
that attempt made (the device it created, and the registry value and settings folder when the
|
||||
driver was not ours before), so nothing looks installed and the next attempt starts clean. The
|
||||
status counts as installed only when the driver is ours and its monitor is there, so a device left
|
||||
without its driver can be installed again. Devices are found by the hardware ID among all root
|
||||
that attempt made: the device it created and, when the driver was not ours before, the driver
|
||||
package, and only when no device and no package are left, the registry value and settings folder.
|
||||
If something stays, the registry value stays too (so it is still ours) and the error says both
|
||||
why the install failed and that something is left to remove. The status says `installed` when
|
||||
the driver is ours and its monitor is there, `leftover` when it is ours without a usable monitor
|
||||
(a removal or clean-up that did not finish), `other` for another program's copy, and `action`, the
|
||||
button the screen offers: `uninstall` for installed or leftover, `install` when nothing is ours,
|
||||
none for another program's copy. Devices are found by the hardware ID among all root
|
||||
devices, whatever their class (a device whose driver was declined has none).
|
||||
The settings: one monitor, one mode (1280x720 at 30 Hz), no custom EDID. When another program's
|
||||
copy of the same driver is installed (its `VDDPATH` is not ours) the app refuses to install or
|
||||
@@ -399,7 +403,7 @@ back as Korean messages for the screen. The Tauri shell passes the screens' `inv
|
||||
| `discord_channel_info` `{id}` / `channel_sync_status` | a channel's Discord name and topic / each synced chat channel's last result (above) |
|
||||
| `collect_results` `{target, limit}` | `{targets, items}`: every target folder with results, and the collected items newest first (`target` null: every target; `limit` 1-500, default 100) |
|
||||
| `mcp_env_status` / `mcp_env_set` `{server, name, value}` | which MCP environment values are stored (`{server: {NAME: bool}}`, never the values) / store one (an empty value removes it); only for a saved server and name |
|
||||
| `display_driver_status` / `display_driver_install` / `display_driver_uninstall` | the virtual monitor's driver: `{supported, installed, other}` (Windows only; `other`: another program's copy) / install or remove it elevated (above), then its status; refused unless the services are stopped or failed, and `service_start` / `service_restart` are refused meanwhile |
|
||||
| `display_driver_status` / `display_driver_install` / `display_driver_uninstall` | the virtual monitor's driver: `{supported, installed, leftover, other, action}` (Windows only, above) / install or remove it elevated (above), then its status; refused unless the services are stopped or failed, and `service_start` / `service_restart` are refused meanwhile |
|
||||
| `install_status` / `install_start` / `install_cancel` | the install steps and their state, bytes and last line / run what is not done in the background / stop it |
|
||||
| `logs_query` `{tab, level, find, after, limit}` / `logs_error_report` / `logs_export` `{from, to}` | the log hub; the zip goes to `logs/` and its path comes back |
|
||||
|
||||
@@ -431,7 +435,7 @@ Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. A
|
||||
switches and one card per MCP server (name, command, arguments and environment variable names
|
||||
one per line, on/off, delete), and for a saved server a password box per environment variable
|
||||
that stores its value on its own; on Windows also a card for the virtual monitor's driver (its
|
||||
state and an install or remove button). The 백그라운드 수집 screen has the targets (a table: name, kind,
|
||||
state and the button its `action` names, so a leftover can always be removed). The 백그라운드 수집 screen has the targets (a table: name, kind,
|
||||
address or words, interval in minutes, on/off, delete), the keep days, and the results (the
|
||||
newest 100, filtered by any target that has results, each with its time, title, link and the start of its text shown
|
||||
as plain text).
|
||||
@@ -515,6 +519,7 @@ while the bot browser runs and off after, one Chrome window there filling the wo
|
||||
the bot's tab, the focus staying in the program the user types into, no taskbar button, no Chrome
|
||||
left after the stop, and the uninstall leaving no device, driver package, registry key or settings
|
||||
folder. On every system: a removal forgets the driver only when no device is left and the package
|
||||
is gone or was not in the store; driver tasks refused while the services start, and a start (and a
|
||||
is gone or was not in the store; a failed install forgets it only under the same rule (and never
|
||||
when it was ours before), reporting both reasons otherwise; a leftover offers removal; driver tasks refused while the services start, and a start (and a
|
||||
second task) refused while one runs, also after it failed. On Linux the same window test runs on an X display (one window at the given place and
|
||||
size, the bot's tab in it).
|
||||
|
||||
@@ -67,15 +67,43 @@ pub fn driver_dir() -> Option<PathBuf> {
|
||||
pub struct DriverStatus {
|
||||
/// Windows only.
|
||||
pub supported: bool,
|
||||
/// Installed by this app (its settings folder is the driver's).
|
||||
/// Installed by this app with its monitor there: usable.
|
||||
pub installed: bool,
|
||||
/// Something this app installed is left without a usable monitor (a removal or a failed
|
||||
/// install's clean-up that did not finish): to be removed.
|
||||
pub leftover: bool,
|
||||
/// Another program's copy of the same driver is installed; the app leaves it alone.
|
||||
pub other: bool,
|
||||
/// The button the screen offers: `install`, `uninstall` (also for a leftover), or none.
|
||||
pub action: Option<&'static str>,
|
||||
}
|
||||
|
||||
/// The status from whether the driver is ours (its registry value points at our settings), its
|
||||
/// monitor is there, and any of its devices is.
|
||||
#[cfg_attr(not(windows), allow(dead_code))]
|
||||
fn driver_status(ours: bool, monitor: bool, devices: bool) -> DriverStatus {
|
||||
let installed = ours && monitor;
|
||||
let leftover = ours && !installed;
|
||||
let other = (monitor || devices) && !ours;
|
||||
let action = if ours { Some("uninstall") } else if other { None } else { Some("install") };
|
||||
DriverStatus { supported: true, installed, leftover, other, action }
|
||||
}
|
||||
|
||||
/// After a failed install: whether to forget the driver (its registry value and settings folder)
|
||||
/// and what to report. Only an attempt that was not ours before and left no device and no package
|
||||
/// (1168: not in the driver store) is forgotten; otherwise it stays ours so the screen can remove
|
||||
/// what is left.
|
||||
#[cfg_attr(not(windows), allow(dead_code))]
|
||||
fn after_failed_install(failure: String, was_ours: bool, devices_left: usize, package: Result<(), u32>) -> (bool, String) {
|
||||
match removal_done(devices_left, package) {
|
||||
Ok(()) => (!was_ours, failure),
|
||||
Err(e) => (false, format!("{failure}. 정리하지 못한 것이 남아 있으니 제거를 눌러 주세요 ({e})")),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn status() -> DriverStatus {
|
||||
DriverStatus { supported: false, installed: false, other: false }
|
||||
DriverStatus { supported: false, installed: false, leftover: false, other: false, action: None }
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
@@ -232,12 +260,10 @@ mod win {
|
||||
devices().into_iter().find(|d| d.string == ADAPTER_NAME)
|
||||
}
|
||||
|
||||
/// Installed means ours with its monitor there (the driver loaded), so a device left without
|
||||
/// its driver shows as not installed and can be installed again.
|
||||
/// Installed means ours with its monitor there (the driver loaded); ours without it is a
|
||||
/// leftover the screen offers to remove.
|
||||
pub fn status() -> DriverStatus {
|
||||
let present = adapter().is_some() || !hardware_devices().is_empty();
|
||||
let ours = ours();
|
||||
DriverStatus { supported: true, installed: ours && adapter().is_some(), other: present && !ours }
|
||||
driver_status(ours(), adapter().is_some(), !hardware_devices().is_empty())
|
||||
}
|
||||
|
||||
/// Put the virtual monitor on the desktop at `corner` and return where it is.
|
||||
@@ -378,18 +404,15 @@ mod win {
|
||||
if (had_device || adapter().is_some()) && !was_ours {
|
||||
return Err("다른 프로그램이 설치한 가상 디스플레이 드라이버가 이미 있습니다".into());
|
||||
}
|
||||
let result = install_steps(&inf, had_device);
|
||||
if result.is_err() {
|
||||
if !had_device {
|
||||
remove_devices();
|
||||
}
|
||||
if !was_ours {
|
||||
let _ = uninstall_package(&inf);
|
||||
let _ = run("reg", &["delete", &format!("HKLM\\{REG_KEY}"), "/f"]);
|
||||
remove_config_dir();
|
||||
}
|
||||
let Err(failure) = install_steps(&inf, had_device) else { return Ok(()) };
|
||||
let left = if had_device { 0 } else { remove_devices() };
|
||||
let package = if was_ours || left > 0 { Ok(()) } else { uninstall_package(&inf) };
|
||||
let (forget, why) = after_failed_install(failure, was_ours, left, package);
|
||||
if forget {
|
||||
let _ = run("reg", &["delete", &format!("HKLM\\{REG_KEY}"), "/f"]);
|
||||
remove_config_dir();
|
||||
}
|
||||
result
|
||||
Err(why)
|
||||
}
|
||||
|
||||
fn install_steps(inf: &Path, had_device: bool) -> Result<(), String> {
|
||||
@@ -558,6 +581,40 @@ fn removal_done(devices_left: usize, package: Result<(), u32>) -> Result<(), Str
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_failed_install_forgets_the_driver_only_when_its_leftovers_are_gone() {
|
||||
let declined = || "드라이버 설치를 취소했습니다".to_owned();
|
||||
// Cleaned up: forgotten (when it was not ours before), the failure reported as it was.
|
||||
assert_eq!(after_failed_install(declined(), false, 0, Err(1168)), (true, declined()));
|
||||
// A device left: kept ours, so the leftover can be removed; both reasons reported.
|
||||
let (forget, why) = after_failed_install(declined(), false, 1, Ok(()));
|
||||
assert!(!forget, "a device left keeps the registry value");
|
||||
assert!(why.starts_with(&declined()) && why.contains("제거"), "{why}");
|
||||
// A package left: the same.
|
||||
let (forget, why) = after_failed_install(declined(), false, 0, Err(5));
|
||||
assert!(!forget);
|
||||
assert!(why.contains("제거"), "{why}");
|
||||
// Ours before the attempt: never forgotten by a failed reinstall.
|
||||
assert!(!after_failed_install(declined(), true, 0, Ok(())).0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_is_left_of_the_driver_can_always_be_removed_from_the_screen() {
|
||||
// Installed and working: remove.
|
||||
let s = driver_status(true, true, true);
|
||||
assert!(s.installed && !s.leftover && !s.other);
|
||||
assert_eq!(s.action, Some("uninstall"));
|
||||
// Device gone but the package (and the registry value) left after a failed removal.
|
||||
let s = driver_status(true, false, false);
|
||||
assert!(!s.installed && s.leftover);
|
||||
assert_eq!(s.action, Some("uninstall"), "the leftover can be removed again");
|
||||
// Nothing of ours: install. Another program's copy: nothing to press.
|
||||
assert_eq!(driver_status(false, false, false).action, Some("install"));
|
||||
let s = driver_status(false, true, true);
|
||||
assert!(s.other && !s.installed && !s.leftover);
|
||||
assert_eq!(s.action, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_removal_forgets_the_driver_only_when_device_and_package_are_gone() {
|
||||
assert_eq!(removal_done(0, Ok(())), Ok(()));
|
||||
|
||||
@@ -27,4 +27,5 @@ fn main() {
|
||||
}
|
||||
assert_eq!(status.installed, action == "install");
|
||||
assert!(!status.other, "nothing this app made looks like another program's driver");
|
||||
assert!(!status.leftover, "nothing of this app's is left to clean up");
|
||||
}
|
||||
|
||||
@@ -392,12 +392,13 @@ async function displayDriverCard() {
|
||||
const label = h("span");
|
||||
const btn = h("button", { class: "btn" });
|
||||
const show = (s) => {
|
||||
label.textContent = s.installed ? "설치됨" : s.other ? "다른 프로그램의 같은 드라이버가 있어 쓰지 않습니다" : "설치되지 않음";
|
||||
btn.textContent = s.installed ? "드라이버 제거" : "드라이버 설치";
|
||||
btn.disabled = s.other;
|
||||
label.textContent = s.installed ? "설치됨" : s.leftover ? "정리하지 못한 것이 남아 있습니다. 제거를 눌러 주세요"
|
||||
: s.other ? "다른 프로그램의 같은 드라이버가 있어 쓰지 않습니다" : "설치되지 않음";
|
||||
btn.textContent = s.action === "uninstall" ? "드라이버 제거" : "드라이버 설치";
|
||||
btn.disabled = !s.action;
|
||||
btn.onclick = async () => {
|
||||
btn.disabled = true;
|
||||
try { show(await api(s.installed ? "display_driver_uninstall" : "display_driver_install")); toast("완료했습니다"); }
|
||||
try { show(await api(`display_driver_${s.action}`)); toast("완료했습니다"); }
|
||||
catch (e) { fail(e); show(await api("display_driver_status")); }
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user