feat: apply visible three-second defaults to unattended prompts

This commit is contained in:
阿白叔 committed 2026-11-16 14:36:56 +08:00
1 parent e4875b4eca
commit efb8cae478
29 files changed
+675 -60

No files matched your search

@@ -0,0 +1,257 @@
{
"schema_version": 1,
"created": "2026-11-16T14:36:55.137608+08:00",
"base_commit": "e4875b4eca1bc487514d479df15f2a4ac92df5e3",
"branch": "codex/unattended-prompt-defaults",
"full_suite": {
"path": "F:\\CbbUnattended-20261116\\full-final.xml",
"sha256": "8717cf87707b525a17eb2a3a292677360eade0d374e7d6eb42a6c2d07209d520",
"tests": 1937,
"failures": 0,
"errors": 0,
"skipped": 0
},
"red_original_no_timeout": {
"path": "F:\\CbbUnattended-20261116\\red.xml",
"sha256": "b0c46ca9c76ce41f9c9053ec94a08d416a3b18d775f3d9e3af1d469ac96b1225",
"tests": 3,
"failures": 3,
"errors": 0,
"skipped": 0
},
"button_and_prompt_integration": {
"path": "F:\\CbbUnattended-20261116\\integration-final.xml",
"sha256": "002f68c353fdf3a6e5eacfd2596df8b15f30a8a76ef3c262d2da3fc64e35a202",
"tests": 100,
"failures": 0,
"errors": 0,
"skipped": 0
},
"first_full_run": {
"path": "F:\\CbbUnattended-20261116\\full-suite.xml",
"sha256": "a6d2d5fe0d240ede5a90fff7b8f4c70635c12b82ef3423185c8ee975db17bf53",
"tests": 1935,
"failures": 6,
"errors": 2,
"skipped": 0
},
"first_full_run_explanation": "Four notification tests expected the old OK button; two recovery-summary paths recreated the Close button and invalidated countdown. Fixed redundant recreation and aligned notification clicks; failed evidence retained.",
"static_api_trial": {
"final_design": "Explicit QMessageBox object; no application event interception.",
"rejected": "Static Qt question interception caused timer ownership/slot errors in experiments; rejected and replaced before final integration."
},
"default_timeout_ms": 3000,
"defaults": {
"submitted_verify_check_management_recovery": "confirm",
"unknown_owner": "skip",
"uncertain_pcb_readwrite": "skip",
"version": "last_user_saved_if_enabled_else_cancel",
"native_cancel": "confirm",
"save_before_close": "save",
"force_terminate": "cancel",
"notification": "close"
},
"compileall_passed": true,
"diff_check_passed": true,
"independent_review": "Final read-only rereview found no remaining actionable issues.",
"files_sha256": {
"src/cbb_refresh_verify/application.py": "62b9b013563a216d020c8366cccb8f949b02afa72dc63c26940804441cc23057",
"src/cbb_refresh_verify/backup_recovery.py": "1d7ef08ef53ca7a0971cdacb0908d9bb06d067b06dc2329fa58722ce9068921d",
"src/cbb_refresh_verify/batch_status.py": "55a4007cf54491ca8e045a5bf86aa4353ac8437cca5a76cd79304962e3d3fa0a",
"src/cbb_refresh_verify/com_runtime.py": "f0f3802d16c791a8bf9dfef44a94917072bfbe8fb3a927d76be8ef0341c7ed35",
"src/cbb_refresh_verify/content_check.py": "8239c17b6e2452917ed573a7deb3e4c8583eaef91bf3630eff5f424d2e398aa9",
"src/cbb_refresh_verify/defaults.py": "a1c03192f4a61ad0924b24bb635705b1ee4811d35483a02864200f95edbbebe3",
"src/cbb_refresh_verify/desktop_worker.py": "27d751816552d215dd8ee9cd67941d824f7b4493120ead7c3f87e5eba5ec4a92",
"src/cbb_refresh_verify/diagnostic_open.py": "d6c49ffe5a9969d95edbbc896d47a7e100f248380a287f99ba7bb8b92dbb3072",
"src/cbb_refresh_verify/dialog_agent.py": "5acb6e5cf1350a7ca20a6fe480668435fac785835874f266881973010db6504b",
"src/cbb_refresh_verify/dialog_models.py": "f68cee01d927b48364276d3c1f79e63ce8af231878db0b907d292780cfbafb56",
"src/cbb_refresh_verify/dialog_probe.py": "d61f0c955c961980c9635940eefb9c7947c1fe90b4b6fd844720df41ddb0aa0e",
"src/cbb_refresh_verify/dialog_rules.py": "3189b476f7ff4678b59212ed7b4081164e038a7cf7662cd895f9019cb3c1edc5",
"src/cbb_refresh_verify/dialog_supervisor.py": "15c415c2d2e916f0b64ba04416164ff3b50996d70b22d3b4ac2226b5547ac247",
"src/cbb_refresh_verify/failed_session.py": "7e6f7fa5ebcf2d49f00c5efc5f5d26412704b68e9122e476ac1f672009a98c09",
"src/cbb_refresh_verify/icdb_maintenance.py": "e81d253d8b4d3e7c1000c45335a392c72b110748675c2c3324ebe524a7252e98",
"src/cbb_refresh_verify/icdb_ownership.py": "7bf2342c1efa34a2ebcbf27964a40a490220f7146fbb6ef957b8d8dd1e511f03",
"src/cbb_refresh_verify/icdb_recovery.py": "358c0e9a004f1e0b2127513286e1dffd94b0180a8b7314aa9655462f570b6360",
"src/cbb_refresh_verify/integration.py": "f188856af69ba25e265988c51db7a6d4263326440d972ca78378b733b891c1ed",
"src/cbb_refresh_verify/library_lock.py": "6836ec8ac21e788eb75326ff44cb31ad4bdfb5f381bd35cdf33e6b34c7fca89e",
"src/cbb_refresh_verify/library_manager_verify.py": "71e16a8581ad44b646be78b480f9812d596a6d162b3eec03d078bf4ea4503195",
"src/cbb_refresh_verify/library_reader.py": "d4007caa361edd467773e49f721e02671d5a9bcb30741769a57349850b12c438",
"src/cbb_refresh_verify/maintenance_entry.py": "3b93c25f69d7a961facd8004e20e155a84cc18f06d57b741a9055786ed058990",
"src/cbb_refresh_verify/management.py": "7ead9bfffeb44201e44f73d9f039590f091e9a456982f2110dca8ec3695f8803",
"src/cbb_refresh_verify/management_transaction.py": "32c53caaead05d5db3a31d3e30721e65434e5837095dc0a7812f825603aa37a0",
"src/cbb_refresh_verify/mentor_adapter.py": "1fc8c98d5508120e03bf001a42dd3e0da7b165eb18c90f1aed83147d17db8638",
"src/cbb_refresh_verify/mentor_paths.py": "ba48c0003b3eacc88906497b2e43b299ca4536a9f7dae44bbacf6a6ec694c116",
"src/cbb_refresh_verify/models.py": "9e8209a8b006df923f1d07ccab64bbcfe5d674c4fc5f5426bfbc9b11da4ee105",
"src/cbb_refresh_verify/native_add_failures.py": "192202732423dc624c5548c75e80bb20973e5087c21d4798c9637f25b6de7e94",
"src/cbb_refresh_verify/native_backup.py": "7276fa3d9298e85550151cf0c7191d84bd08a18a72df5d854a3c38f1a88b001d",
"src/cbb_refresh_verify/native_engineering_identity.py": "8c0fc144707d68a9b85f6da50ef950f1f6e7fee248acbf34d19b707d51212be0",
"src/cbb_refresh_verify/native_export_guard.py": "523cdf44db8e1665634feadba963ccf26777dc8942fb2eb604d2c30bbe92cbb6",
"src/cbb_refresh_verify/native_management.py": "eb2ec311489eaf5deb06893a54a02469c9b2bb9baccbdd6563bae295aafcf363",
"src/cbb_refresh_verify/native_occupancy.py": "7d686079d12217382adace6361cd343d977b91075e3b157cf410ca92d07ffc49",
"src/cbb_refresh_verify/native_repair.py": "9f024dcb5e3a76369191033474fefd30787b6ae350c315f3cf38e92e5a1f3e98",
"src/cbb_refresh_verify/native_repair_ui.py": "3eb2af181befea94af8b3b3131edff09589f340bcba777abbe3b67fd31b80393",
"src/cbb_refresh_verify/network_path.py": "6b5b159502d42a46bf4ee26d5698fd2c6498b359088e2138eae46e9065b13c6f",
"src/cbb_refresh_verify/operation_lifecycle.py": "3838c5a501711d16f578c45ebbc6f960872b0c3ba6bbda9a597f994ef746cef6",
"src/cbb_refresh_verify/operation_queue.py": "a6932d8bc68ac436091f6d362557c66d274ec52d0f295a22f014a3396845c79f",
"src/cbb_refresh_verify/owner_probe.py": "8dcfd60246cb2979db34d02e0a2d605c334b6f7e2666f22daa2f50c0408bc903",
"src/cbb_refresh_verify/pcb_bridge.py": "2f6c2b09642100468814500569dbfc6695fc2a46b9a3b8333daa8e1530cdeef5",
"src/cbb_refresh_verify/pcb_open_consent.py": "fd56dfe0b537408745127d80ea68cc59d3f333954af76bac7a7b324d66badc65",
"src/cbb_refresh_verify/pcb_restore_prompt.py": "a488ab48845173f463042c17ad1e719fe37a4bcf98a660f06453eef171b0e7bb",
"src/cbb_refresh_verify/post_repair_consent.py": "3b1eaff1db58fd311a9dbc5fdcd850911b04cc5afd4e747f70a62b721b8fafa4",
"src/cbb_refresh_verify/post_verify_diagnostics.py": "2442de485bc0d6a34c4b2d9b10bc5f323ea38f9ff66674119a50f5c6043bac63",
"src/cbb_refresh_verify/reimport_recovery.py": "ef148549751fa47518f5f2ca8f32ba25794ec5f22e0de545476ea33f89a3f0bf",
"src/cbb_refresh_verify/residual_sessions.py": "4ac500b33b209611d54eb496c6c30727ba159742d625431ceea84471a5fc3442",
"src/cbb_refresh_verify/runtime_logging.py": "44ac25430a89c5ffc9e48e88c227e88052f4c815365e8556f67918f3edaba39e",
"src/cbb_refresh_verify/runtime_timing.py": "c4ed4057b5000e0b86ccc7dd1fe2004d6e0dae29f397fec77b01ad41a81c6367",
"src/cbb_refresh_verify/scoped_manifest.py": "9318bf0f929d23c18466a25d83a4a9903822093c123aae10510061788c6d0ab7",
"src/cbb_refresh_verify/session_record.py": "2bc3cff365008864584138a4ff13538bb6b2f90d981e7d008a1300f9102c6e7e",
"src/cbb_refresh_verify/status_bridge.py": "05d627d02934a14f5de409472c291d37565a95b836f9c130111aae80612e9196",
"src/cbb_refresh_verify/verify_diagnostics.py": "041b77d7d49e4c86338ed5e5741d0d27a2c42bc358f4da54b3efe64af847e9b8",
"src/cbb_refresh_verify/verify_probe.py": "3ed743df49d195c74f5045985ab23491d103ee2c42c07b558c1e037176402ed2",
"src/cbb_refresh_verify/verify_runner.py": "3027ef7fc1ef6365ff36ae0c83389d869b92ffcd96985d10275bca4dc9483e3f",
"src/cbb_refresh_verify/write_admission.py": "c5f879bd5cb70a5dedfc64349c8758bf370daa4240491addd2aecd344f3a935c",
"src/cbb_refresh_verify/__init__.py": "75942b10cc5c09f19d5f31bedd0395361642336f52bc9e9872d8483e3b9882f9",
"src/cbb_refresh_verify/__main__.py": "dc4be034a0e43d4b659a9300137c29a6a6b7a32b7eaef02b6dff9a88c41305c0",
"src/cbb_refresh_verify/ui/backup_notice.py": "1a3fa5ac18a267907faf95f36d61b9f08bcbb939eef4d480dd06af1391a81599",
"src/cbb_refresh_verify/ui/backup_recovery_dialog.py": "8a80f584347f3fdefc089169894712746fee85f079b029578f008d6aecec8d90",
"src/cbb_refresh_verify/ui/icdb_check_task.py": "ade3bf414aa29b42f4c1535c613b2cacb2735f6abc7900e6da25999390a5891d",
"src/cbb_refresh_verify/ui/main_window.py": "f72062cb3d97cbd38f6390b9483e0f3aab619dec0bb2292c02d32b7fc5cd84b9",
"src/cbb_refresh_verify/ui/management_dialog.py": "57698f42112b120899dac26c40d2aafb4b5ba719660a302c0460361a7d50609a",
"src/cbb_refresh_verify/ui/pcb_open_dialog.py": "1b9689d555d221567263b6b587250b51a11bef276c35d64393e1b3d13803c625",
"src/cbb_refresh_verify/ui/pcb_restore_dialog.py": "11479db5520310af37824e083cb678d69d4cfd12f70dcd29ccb906b929e3d9bd",
"src/cbb_refresh_verify/ui/residual_release_dialog.py": "a0bdcc091778d508c43a6af96bd6423b25cd029c92b6bcff22d459d09a030d06",
"src/cbb_refresh_verify/ui/timed_prompt.py": "71db65febd0aff9117dcee42dde5151a7f13a3337794c77031cf5585f0397d97",
"src/cbb_refresh_verify/ui/workers.py": "4cc9360a4820ded27a7d5ef709fc9f04b1d4804cb1e7a614f6c357ed547da888",
"src/cbb_refresh_verify/ui/write_owner_dialog.py": "65dc3c8287f4ac5dc767797c13e192f6bd916f9051570a33a2b18f4f8334c3b3",
"src/cbb_refresh_verify/ui/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"tests/button_simulation.py": "3278868565853001103557d5f7ada42b11b05c03feb9032deed0327b6609de2b",
"tests/test_abnormal_shutdown.py": "0abdeaf51e2ffc3f771e09aefa9ec647a72b7f64757c9f3851926fbd392cbbcd",
"tests/test_all_buttons.py": "a075cfdf3223b754be351db54844f94a8538519c38a12b1b575ec483c544d57c",
"tests/test_application.py": "bba12187fca6fee0f4f8862182bb40d939e2995016af2cdbb3fd756f6a99135d",
"tests/test_automation_license.py": "45e9c75d0d3e1a76f997f7da4cc87b5eb1b05a4ea2356408725742eac8a09ffb",
"tests/test_background_icdb.py": "df9bd9e8252e0dee4527dc6a740c0c33e76d1fb06a79b816cc15809d95716e44",
"tests/test_background_queue_regressions.py": "132866bfccc9a7ac5cb234f97aaf6a290e2e4ef949f31e2f70b0f3eafeb99046",
"tests/test_backup_recovery.py": "efd88c0c00440ac915b147c2e6dee8044ca805b03f90ab9f171cbde1db11cb9b",
"tests/test_backup_recovery_dialog.py": "24a120e45dee151bc71a2e1a05345936c5063bf0f57a277af02ef3a6bfd753f9",
"tests/test_batch_blockers.py": "4387293d3a5820fab630e3c5fe1b424f61ba6947773e5a61125d840433c5c62a",
"tests/test_batch_item_yield.py": "ed4be6d1e854b18d054a75c92171cd46b6b64411c2f74e9a3caf31fba3c7366b",
"tests/test_batch_status.py": "c1f9af0c7c6f3171b3726fb53346f480b13b8d9cd88111a9c12e2fae2392bbff",
"tests/test_batch_status_faults.py": "314e890c9aee439c8a75b4dfd605685240c74f6212da975fd50526bd70b4a0ff",
"tests/test_desktop_worker.py": "671d616f04a01d74508b328e3b6fc8f6c7191a91de0dcaa486aa98a3718353ff",
"tests/test_diagnostic_open.py": "b44f8f7b171602ad2691ea2e064ac9fe94f2fabb9fcc2eb6760cc1dd365b9423",
"tests/test_dialog_agent.py": "8c746e47d55637ca18d7cc998f324a0c2e0a5214dcfe8fcb6458c060619c211c",
"tests/test_dialog_models.py": "6902cf5c292458340fb48241b34875e111a0113d706cd82775934a7f72bab7b9",
"tests/test_dialog_probe.py": "55c98f6102957a27a96dcfd4f4bf3af499b5055225b77ef93b7b332dfd4ac472",
"tests/test_dialog_rules.py": "96bf36493da770679e9207e96b3088ef7f471aea22e17c254f33326ffef0d7f9",
"tests/test_dialog_startup_budget.py": "6f23c01836e4894ae82c3345a2383c4f8eb0517056c5b953c43100acd0fc3739",
"tests/test_dialog_supervisor.py": "4c1b00050127a65b0a8cf1c7a94fd673431ea3f04b76033a463804d0468ad2d9",
"tests/test_extended_safety.py": "7450816abba89aba1f4739f819f43631def82701fe07481279db2b3f3ed96cf6",
"tests/test_external_owner_release.py": "675ddbab4a97e86febac3003b9083c259295534941aa0463488a5a1206cfaf92",
"tests/test_failed_startup.py": "eca757ea46a4c0aa4fb0368ff53f26822af71612d251ecd87132686fe3c3794b",
"tests/test_failure_lifecycle.py": "dfeac56744a44e6f4c7898516749ca478f53d7c7f08b3843a05ef7f448c469a7",
"tests/test_icdb_address.py": "cbdc07e5043349c796a4ea1ce3d4989062094cd28929a9ef7d42c5ba75b77907",
"tests/test_icdb_batch_check.py": "79b4a8d9576449bde64f06bfd4d30b82ce6fe93e055c238eb1f239e75b472579",
"tests/test_icdb_open_check.py": "1f3750169755d0553bac3e0f8bec244038b84f9cd970e17c9f6eb67dee0e3dba",
"tests/test_icdb_recovery.py": "298ddac4b79b4400efc99ff27c58ca49fffea1f401a31071451b2fdaca59036e",
"tests/test_import_without_export_gate.py": "2f249412736cbe84f0c82db82403212739b7c53355f87cd053587ccdb722b175",
"tests/test_incident_safety.py": "52f3ccb04db8971bf38628c2bd334d4fd79795e97de6538f6f66cb35f7123ece",
"tests/test_independent_operations.py": "4ba5798df3346bce74c3703c158f1dce1d1ba14df748606fcaf900c8568753e0",
"tests/test_integration.py": "9e9d30692607c889e1e3744a63c79c68e3af7d4c86804e0bcebe48e68765086c",
"tests/test_late_release_continuation.py": "34c62a628cbc08f4e8b9a1919c13f17772a2d26d1996fae34a35f814725b00e2",
"tests/test_library_lock.py": "3d65bd941faa441404045ce0140ea3ea5e58fb7d410b7b76bb9f03a9ea03d3af",
"tests/test_library_reader.py": "b39a1dc9d99c2463b744141e3c3489cd49ac4a637e7835559a9c3fe9cbafbb58",
"tests/test_lifecycle_supervision.py": "cfe29f1e73c6ef38d11e185e211b6e2fb60247f53a44e99dd1e2f8cf7a009faa",
"tests/test_maintenance_diagnosis.py": "0849aef555475a03b061eacf499f261fb75f2e727f35dba3cbceafac92e2a638",
"tests/test_maintenance_entry.py": "5ed3cda8e0c829fb2964e27f1bdc6fa8ee8dcde93ec63338959bf754b62d6a0b",
"tests/test_maintenance_owner_scope.py": "7cf64dc7f2b126684dcac6e619cbd87eca3d85ec2fc1f70f057154679dad6026",
"tests/test_maintenance_review.py": "ba807fd8c25c1b52cf2443d8bcf2f57539819715c0bc6c358d31d8542c2e7ce5",
"tests/test_maintenance_startup_gate.py": "4f69d33218483a658b51b2012ae8bfa83aff8a787152a38b19dadc4c0d3ffe36",
"tests/test_maintenance_ui.py": "9c604714b0742503dbd55b243161a01f4ae62fa0cae7c4cddec7a2b8c81d07ab",
"tests/test_management.py": "cad0fb43eca9e7022a33a5e9ff0a408465b262fd304b146cdc85c28265f2e74f",
"tests/test_management_diagnostics.py": "671a9d7c112ededbee332db9b6fbab786fb37e9367d992f902f3ab2c9f60880b",
"tests/test_management_native_transaction.py": "7ca227aae6426c4d0d998edfd8620ec18905aaf212f0be20ceba97b1cde3a9a4",
"tests/test_management_probe_guards.py": "ae9be3dbd7c6a616478b7d4ea3498c428ff94a985089fe798463c5cab456f151",
"tests/test_management_retry_blockers.py": "124dbef291dbe331ba0c3e7de1665c910ea43e37b1563429b387f0f2233953ee",
"tests/test_management_source.py": "16e608ed9c8b0aa81cf08d49f165a33a1403c4ea7f2a5be44e8cfc8cb49850ad",
"tests/test_management_supervision.py": "2dcadd6551a94c52e5d4e74285959f10144a89c48af87e508abaea945652d1f6",
"tests/test_management_ui.py": "3d02dd00f20227aba6eeff40b9c49e34c93f81b02a02370fb0fa6848a1981413",
"tests/test_manual_backup_ui.py": "c1d3f7363a18ad3a690854d503199aa703c0a11ef937c933b025fd9b98083ed7",
"tests/test_mentor_paths.py": "a05a91812a74b58e76f36d581216ee43969d2576b8a8e7d1cde3e301c52cf4c1",
"tests/test_native_add_failures.py": "ceedd60e030628b1af149d08d16216d5f7158a63686729bb357c148da86fb0ec",
"tests/test_native_backup.py": "43ec0c6b14b53864553feaf5d9fb498b37866f24edc486c0749160d3f803db5f",
"tests/test_native_engineering_identity.py": "a1adcf6883a9b55c2c37d9f491faf40dd4928f4d8db675419fd288dd31552c69",
"tests/test_native_export_guard.py": "f8ec4fa1058af55008e9628f79f2dc70b6e551f36815a812d10bfdf955cada51",
"tests/test_native_inspection_release_regressions.py": "8f7bb0b2b641d437872f1dd1d0c2547c2522c81e3c0351c31a7125f751d91927",
"tests/test_native_management.py": "badf33d4d00104c7e96e336777fb3e49690cc9db5ce1b071f98520aa5b6668f1",
"tests/test_native_management_fields.py": "9917ca0910e19bd809c86d0120c652145261528ace33c3b805f5663442c4a973",
"tests/test_native_occupancy.py": "56293dbe24bd3cd4f74cf8208e933faab7d737e5a5684a5d38838d063c3aef6d",
"tests/test_native_repair.py": "113185ced72d8f4f4eafca99054d97fe80a504d1c6cc91aaf86f55cea1b7e138",
"tests/test_navigation_tabs.py": "d7d5bbfc752f73c1b1d4615ffafc1266e772d96f3f3ba3d82c4b4baf678b292d",
"tests/test_network_path.py": "f52624391ae78e9b913dace2b1a9a2875a5855f86dc9e12c324ef493e6c7817b",
"tests/test_network_release_safety.py": "caef536d0a40b2eb848c1b8ab095ab374af247c03dd44acf8a70f0f500db6dac",
"tests/test_operation_lifecycle.py": "c0ce6c86b73021a8b162ae9e67a10aeec8a27a98e382fd82e1449a451a9a8c3c",
"tests/test_operation_queue.py": "8137528603f015695ed4d60a0c8fa8e7bf0a1c4659f8dc2a181291f5d500e6a1",
"tests/test_owner_probe.py": "deb757e022980f11ef48e57a2fd002ee3e90ec647a4666a0c4d4427313b6f725",
"tests/test_packaging.py": "87a6d04419775c0c5c806e0e569a48d7ef199a0bff8736b211443a1f471e7e8a",
"tests/test_packaging_status_bridge.py": "cbfaeac070a1494a1d8609fc25e9a779a63354c8914b4c6c57fdc7c31b70d472",
"tests/test_pcb_bridge.py": "527fb63147a203a2e9419da989aff600d3e461580989e39e8ede3a8cc57b901a",
"tests/test_pcb_open_consent.py": "ec94b5b73790d7e0caf7140783e73e4a32a21b787f80a427e96fc7083f33535a",
"tests/test_pcb_restore_prompt.py": "a005691d0296587e520e20c4430e9e55227d767c8e910e950a9f2e93aeccb2c7",
"tests/test_pcb_version_choice.py": "0825c28333e4ed4f5a63847b6f5bb11143e922c7203d2770ce9c78fc8edec20f",
"tests/test_post_repair_consent.py": "bf417b378255386dc97ad8efdf5003b0691aa5d69da9d9256aa367dc16a2d4bb",
"tests/test_post_verify_diagnostics.py": "212857e56581998a3a3cd53635030b68a089fc4d630a8b0ee7ef3f137090dcc4",
"tests/test_private_desktop_discovery.py": "5361493313ae6864e252cdb9f2c72e71b39264a1c022beb4cf0c04c143cdd91e",
"tests/test_readonly_status_policy.py": "3ed40d7bdf2d3e6f70b38803b89a8b982336556444b45c6ba6b0a7c6df52a97f",
"tests/test_reimport_recovery.py": "2c0ecf52cd6c393f572c11b5d998a78ef538f7a277668cdc329a03e267074650",
"tests/test_residual_release_dialog.py": "1d5efa03cfe013770e2b81e1fcfb669142f5d6a07957110e56a3cc5eeb57c4a3",
"tests/test_residual_sessions.py": "2c51ed1dc95a3afa7ebb24027963dfa9d13aba9c407e508e22ccc6e9f762dfeb",
"tests/test_review313_residual_isolation.py": "52a8024ed4e2a7fed219fe46cacdf76fa971166feedd557206716ef7f6d3c914",
"tests/test_review326_dispatch_and_receipts.py": "ce4d529246da1c4d53c3dec70ef49542165064404301dec3e32851df62492ecf",
"tests/test_review326_queue_guidance.py": "305662f79251669685a618bdd35d524ef2b37eaece4428bb58ae4c5b65abb8ac",
"tests/test_review345_ui_cli.py": "795e7e4f9bda8874c6a65a08863cab19f4adb3412287276ee2960588f0fd2fa8",
"tests/test_review348_release_comparison.py": "ceccdb3d6f7bc6cb65562c059f13aa2bc5d89d98c6f64b0f11d9b943ebbde165",
"tests/test_review381_queue_release.py": "e0d62424cbf70ec9573db78ede0a4c6534775399194eed4c6b28ba8d468307be",
"tests/test_review391.py": "304d46d63af87ea4a9bca83834b77cc44c5c9addf7b0f3752431304ee612568c",
"tests/test_review414_export_and_audit.py": "ec785c2656bed97de6c8467885f2ad0877b55ee872b02928744d399e8767d8a0",
"tests/test_review414_open_and_queue.py": "db065207dacaccd0bd80af52c1f1edaf36a278e7cf2dce7c9b44bc51dd0e1cec",
"tests/test_review414_write_admission.py": "732a3683c2e27331cd5a9645e062e22613f848cac1a12745744fe249b48a9ffe",
"tests/test_review430.py": "7350f3883ddb9be48cc66fa7b0f612e1b45acf2298c80a7faa3da1f05d6d4c83",
"tests/test_review_319.py": "831fd34d426abb4436b9132bfb7ed754994155a34ac60a59378dee0964b54d28",
"tests/test_review_backend_followup.py": "2f3f51a72ecd05fc33c6b5a8dddaecfd12d2b50df423c87b4c18d1e52b2609bd",
"tests/test_review_foreign_release_evidence.py": "cbf2af02418f6bd3ec720a7a7658cf97f06d1a6e12009fdff2a99f465711591e",
"tests/test_review_management_ui_followup.py": "746602a84c3ba9cb041c5dd354b39d344355b71a3666b27a47eb9aee231e171c",
"tests/test_review_release_followup.py": "8779bde7aaaf59ecf362990afe1d9e7ed4ecb1f6fd7653c08bffbdc296200837",
"tests/test_runtime_timing.py": "7152cd8fedfe165e769dadc1238c347d9f4d3e93cd57f6ed991e14d959e720f7",
"tests/test_safety.py": "ccf5febaf0a974d5e5357398a6946d3f121e07a6247c2f0dc5b71d86b39cac52",
"tests/test_save_helper_identity.py": "178a68c4a9a8c618dad3d8393e816dd1d2a16aef8d1fb9984117fe9dc8d06add",
"tests/test_save_helper_runtime.py": "00b092ec799da4bca424e1ee63a83bee783c81dbcdc20b7526fda8b45bb4b72a",
"tests/test_scan_isolation.py": "cab02bfe55ed515f889d3fcba6e6880344f482cc3a78a072b543b7a871cf92ab",
"tests/test_scoped_manifest.py": "fe9b2047d2c43812e851dd89ff250a2e5907dda89b3f5d9ae0a4dc4c5f452eac",
"tests/test_session_record.py": "6b51b19adfb232275195da7ff1ba91a5ce5e296f9424a7a1a29fc67ecfdfb108",
"tests/test_status_bridge.py": "fe1c0632d4d5fd5a1caf221903d4cfe38eda62aaa4298e3438735e31b8459ab2",
"tests/test_status_bridge_server.py": "7d8cd72d69afae0f96ebbd9bb3be2ae3c222f01108e45ab51a09e54d4d8527cc",
"tests/test_ui.py": "ec0aad6d58b81a42129709b4cbeda9e754be48c6107a5b12384f75170c983463",
"tests/test_ui_batch_safety.py": "12a8d82d4aedbeee315a02a49ec0e9888547ad4abd63e181e7f392b2a39e26dc",
"tests/test_ui_filters.py": "d542e3d6fbc8cff64229b31ea8d0ed14ae0fe0c2c03b6a6eefed2f57dfbe77c9",
"tests/test_ui_lease_lifecycle.py": "18ea8af868373fa795a4911754be55068fe75833ce35579c1212fd7f4713f149",
"tests/test_unattended_prompts.py": "9dff94c678af95b796dfc068bb478de720547dad0b341a63195ca97710f2c4af",
"tests/test_verify_diagnostics.py": "b6431194e9f4c86a42110cac0d5f712c27b063f43b4ce820327aded81602908c",
"tests/test_verify_probe.py": "aeb65b5bd2df14e8a8f3ba5501855b5946e6f8a22f0d26960c00ff1b0daea56b",
"tests/test_verify_runner.py": "e58619f55873302c39129ce50e50fb25173a96ab309d975aa4f47f0bd3459fbb",
"tests/test_verify_worker_stability.py": "eae03400c2e3c8a0bc339c8dc05d890403c6bfb4c6d70d0361bc1b882b47d618",
"tests/support/runtime_lifecycle_frozen_boundaries.py": "bf98533a1c06ccf4453d20b3804323779719e697141b8dc64fa679960a979cfd",
"tests/support/runtime_lifecycle_frozen_fixture.py": "b87761c06a300f0d93bce864d3d31e045f2135324b2a9a42f8682ccbff09ad22",
"tests/support/runtime_lifecycle_frozen_smoke.py": "65b530d1e18b35918595eddc7cedeb31ff204cc785b1dc3c0d8c0b87f4aba0a5"
},
"production_logs_read": false,
"mentor_started": false,
"production_library_modified": false,
"published": false,
"automatic_icdb_repair": false,
"limits": [
"Only confirmation-message waiting is changed; global busy/queue/I-O locking design remains unresolved.",
"Native write, real occupancy and exact process/window checks still govern continuation.",
"Native Mentor unattended end-to-end, Windows 10 and cross-machine SMB not accepted.",
"File selection and configuration forms require valid input; unknown native prompts are not guessed."
]
}
@@ -0,0 +1,47 @@
# 无人值守弹窗默认动作
从 beta.3 主分支 `e4875b4` 开始的本地修改。此记录不是云端发布公告。
## 之前修复为何仍有阻塞
此前以局部失败案例逐处增加保护,未完整验证各层的组合。界面 busy、原生队列、库租约、历史检查点和会话释放共同决定能否继续;释放动作还可能等待被阻塞的同一队列。
“发生错误”“本任务仍占资源”“外部占用”“界面正在执行”几种状态未充分分开,导致恢复入口也被保护条件禁用。
单项失败后继续的用例通过,只覆盖了可返回的失败;没有覆盖首次读库带锁、取消、换库、释放及关闭的完整闭环。
本轮只消除确认弹窗无限等待,并给出明确默认动作;全局队列及锁的结构问题仍需单独修复。
## 默认动作
所有下列消息框显示倒计时,在可见且无人选择时 3 秒后执行指定默认动作。
手动选择、关闭窗口会停止本轮倒计时;不会在窗口消失后执行旧操作。
| 场景 | 默认动作 |
| --- | --- |
| 已点击执行的普通校验、ICDB 批量检查 | 确认开始 |
| 已预览并提交的新增、替换、移除 | 确认执行;原有逐项检查及人工备份提示仍在 |
| 已选择完整来源的备份恢复确认 | 确认执行;副本验证及安装前检查仍在 |
| 已明确请求的原生取消 | 确认发出原生取消请求 |
| 已进入释放流程的“关闭前保存” | 保存后关闭;不默认放弃未保存内容 |
| 未知原生客户端占用确认 | 跳过本项,不给未知客户端授予写入许可,不取消整批 |
| PCB 提示上次未正常关闭或仍被占用 | 跳过本项;实际释放成功后才能执行下一项 |
| 原生历史版本选择 | 沿用用户此前明确偏好的“最后手动保存”;该候选不可用时取消本项,不改选自动保存 |
| 强制结束客户端 | 取消,不自动强杀 |
| 结果通知、原生详情通知 | 关闭;记录仍保留 |
选文件及填写来源等配置窗口需要有效输入,不猜测工程路径。
未识别的原生弹窗不猜按钮,也不使用鼠标前台抢占。
## 证据与边界
OpenChoice / RestoreChoice 保留一次选择,新增 `decision_origin=user/timeout_default`;原生 PCB 选择记录与动作载荷写明来源。
未知客户端超时默认跳过,不生成“用户已确认无人使用”的许可;逐项结果保留超时原因。
所有原生身份、窗口按钮、地址记录、文件占用、保存和释放证明照常执行。
倒计时不会解除真实资源占用,也不代表 ICDB 已修复或工程 READY。
测试包括实际等待 3 秒、人工提前改选、首选版本不可用、窗口隐藏/关闭后计时失效、一次性决策以及选择来源。
测试不使用生产日志,不启动生产 Mentor 工程。
最终全量 1937 项、逐按钮及弹窗集成 100 项通过,编译及差异检查通过。
首轮全量发现通知框重复创建标准按钮导致计时对象失效,已删除重复创建;首轮失败证据保留。
完整散列和测试记录见 `2026-11-16-unattended-prompts-validation.json`。
当前仅本地源码提交,没有重新冻结、推送或更新生产发布包。
+9 -3
View File
@@ -18,14 +18,16 @@ class OpenChoice:
def __init__(self, block, library): def __init__(self, block, library):
self.block, self.library = block, library self.block, self.library = block, library
self.decision = None self.decision = None
self.decision_origin = None
self._lock = Lock() self._lock = Lock()
def choose(self, decision): def choose(self, decision, *, origin='user'):
if decision not in ('continue', 'skip', 'cancel'): if decision not in ('continue', 'skip', 'cancel'):
raise ValueError('无效的打开工程选择') raise ValueError('无效的打开工程选择')
with self._lock: with self._lock:
if self.decision is None: if self.decision is None:
self.decision = decision self.decision = decision
self.decision_origin = origin
def validate_owner(job, target_pid, launcher_pid, worker_pid): def validate_owner(job, target_pid, launcher_pid, worker_pid):
@@ -106,9 +108,11 @@ class OpenController:
action = {'action': 'user_confirmed_pcb_open', 'channels': ['win32_button_click'], action = {'action': 'user_confirmed_pcb_open', 'channels': ['win32_button_click'],
'target': {'control_id': control}, 'desktop': self.job['desktop'], 'target': {'control_id': control}, 'desktop': self.job['desktop'],
'pid': target_pid, 'owner': owner, 'choice': self.choice.decision} 'pid': target_pid, 'owner': owner, 'choice': self.choice.decision}
action['decision_origin'] = self.choice.decision_origin
def send(): def send():
_write_json(Path(self.job['root'])/'pcb-open-user-choice.json', dict( _write_json(Path(self.job['root'])/'pcb-open-user-choice.json', dict(
choice=self.choice.decision, project=self.job['project'], pcb=self.job['pcb'], choice=self.choice.decision, decision_origin=self.choice.decision_origin,
project=self.job['project'], pcb=self.job['pcb'],
library=self.job['lmc_file'], owner=owner, snapshot=snapshot.to_record())) library=self.job['lmc_file'], owner=owner, snapshot=snapshot.to_record()))
self.sent, self.sent_at = True, time.monotonic() self.sent, self.sent_at = True, time.monotonic()
return perform(snapshot, action, snapshot.phase) return perform(snapshot, action, snapshot.phase)
@@ -128,8 +132,10 @@ class OpenController:
error = 'PCB_OPEN_ANSWER_FAILED' error = 'PCB_OPEN_ANSWER_FAILED'
if not error and control == 7: if not error and control == 7:
error = 'PCB_OPEN_SKIPPED' if self.choice.decision == 'skip' else 'USER_CANCELLED' error = 'PCB_OPEN_SKIPPED' if self.choice.decision == 'skip' else 'USER_CANCELLED'
skipped_detail = ('超时默认跳过本项。' if self.choice.decision_origin == 'timeout_default'
else '用户跳过本项。')
return DialogPollResult(activity=True, action_sent=True, snapshot=snapshot, return DialogPollResult(activity=True, action_sent=True, snapshot=snapshot,
error_code=error, detail=result.detail or ('用户跳过本项。' if control == 7 else ''), error_code=error, detail=result.detail or (skipped_detail if control == 7 else ''),
accepted_controls=result.accepted_controls, channel=result.channel, accepted_controls=result.accepted_controls, channel=result.channel,
action=action['action'], observed_snapshots=tuple(snapshots)) action=action['action'], observed_snapshots=tuple(snapshots))
except Exception as error: except Exception as error:
+10 -2
View File
@@ -13,14 +13,16 @@ class RestoreChoice:
self.block, self.library = block, library self.block, self.library = block, library
self.candidates = tuple(dict(c) for c in candidates) self.candidates = tuple(dict(c) for c in candidates)
self.decision = None self.decision = None
self.decision_origin = None
self._lock = Lock() self._lock = Lock()
def choose(self, kind): def choose(self, kind, *, origin='user'):
if kind != 'cancel' and not any(c['kind'] == kind and c['enabled'] for c in self.candidates): if kind != 'cancel' and not any(c['kind'] == kind and c['enabled'] for c in self.candidates):
raise ValueError('Unknown or disabled PCB restoration version') raise ValueError('Unknown or disabled PCB restoration version')
with self._lock: with self._lock:
if self.decision is None: if self.decision is None:
self.decision = kind self.decision = kind
self.decision_origin = origin
def _candidate_key(candidates): def _candidate_key(candidates):
@@ -82,7 +84,11 @@ class RestoreController:
if self.prompt.decision is None: if self.prompt.decision is None:
return DialogPollResult(activity=True, observed_snapshots=tuple(snapshots)) return DialogPollResult(activity=True, observed_snapshots=tuple(snapshots))
if self.prompt.decision == 'cancel': if self.prompt.decision == 'cancel':
raise ValueError('用户取消 PCB 版本选择;未确认恢复,保留原生现场。') _write_json(Path(self.job['root'])/'pcb-version-user-choice.json', dict(
project=self.job['project'], pcb=self.job['pcb'], choice='cancel',
decision_origin=self.prompt.decision_origin, snapshot=snapshot.to_record()))
reason = '超时默认取消' if self.prompt.decision_origin == 'timeout_default' else '用户取消'
raise ValueError(reason+' PCB 版本选择;未确认恢复,保留原生现场。')
selected = next(c for c in choice['candidates'] if c['kind'] == self.prompt.decision) selected = next(c for c in choice['candidates'] if c['kind'] == self.prompt.decision)
if not selected['enabled']: if not selected['enabled']:
raise ValueError('PCB_VERSION_DISABLED') raise ValueError('PCB_VERSION_DISABLED')
@@ -99,12 +105,14 @@ class RestoreController:
action = {'action': 'user_selected_pcb_version', 'channels': ['win32_button_click'], action = {'action': 'user_selected_pcb_version', 'channels': ['win32_button_click'],
'target': {'control_id': control}, 'desktop': self.job['desktop'], 'pid': target_pid, 'target': {'control_id': control}, 'desktop': self.job['desktop'], 'pid': target_pid,
'choice': selected['kind'], 'candidates': list(self.prompt.candidates)} 'choice': selected['kind'], 'candidates': list(self.prompt.candidates)}
action['decision_origin'] = self.prompt.decision_origin
if self.owner is not None: if self.owner is not None:
action['owner'] = self.owner action['owner'] = self.owner
self.selection_sent = True self.selection_sent = True
self.confirm_sent = confirming self.confirm_sent = confirming
self.sent_at = time.monotonic() self.sent_at = time.monotonic()
record = {'project': self.job['project'], 'pcb': self.job['pcb'], 'choice': selected['kind'], record = {'project': self.job['project'], 'pcb': self.job['pcb'], 'choice': selected['kind'],
'decision_origin': self.prompt.decision_origin,
'date': selected['date'], 'historical_restore': True, 'confirm_sent': confirming, 'date': selected['date'], 'historical_restore': True, 'confirm_sent': confirming,
'snapshot': snapshot.to_record()} 'snapshot': snapshot.to_record()}
_write_json(Path(self.job['root'])/'pcb-version-user-choice.json', record) _write_json(Path(self.job['root'])/'pcb-version-user-choice.json', record)
@@ -8,6 +8,7 @@ from PySide6.QtWidgets import (QComboBox, QDialog, QFileDialog, QFormLayout,
from .workers import ServiceWorker from .workers import ServiceWorker
from .backup_notice import MANUAL_BACKUP_NOTICE from .backup_notice import MANUAL_BACKUP_NOTICE
from . import timed_prompt
class RecoverySignals(QObject): class RecoverySignals(QObject):
@@ -88,10 +89,10 @@ class BackupRecoveryDialog(QDialog):
except Exception as error: except Exception as error:
self.status_label.setText(str(error)) self.status_label.setText(str(error))
return return
if QMessageBox.question(self, '确认从备份恢复', if timed_prompt.question(self, '确认从备份恢复',
f'{MANUAL_BACKUP_NOTICE}\n\n目标库:{request.lmc_file}\nCBB:{name}\n来源:{source}' f'{MANUAL_BACKUP_NOTICE}\n\n目标库:{request.lmc_file}\nCBB:{name}\n来源:{source}'
'\n\n将创建用于校验的隔离库副本,校验通过后替换目标工程。确认继续?', '\n\n将创建用于校验的隔离库副本,校验通过后替换目标工程。确认继续?',
QMessageBox.Yes | QMessageBox.No, QMessageBox.No) != QMessageBox.Yes: QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) != QMessageBox.Yes:
return return
self.busy = True self.busy = True
self.stop.clear() self.stop.clear()
+8 -5
View File
@@ -47,6 +47,8 @@ except ImportError:
from cbb_refresh_verify.ui.workers import ServiceWorker from cbb_refresh_verify.ui.workers import ServiceWorker
from cbb_refresh_verify.library_reader import read_library_fast, scan_open_library_status from cbb_refresh_verify.library_reader import read_library_fast, scan_open_library_status
from cbb_refresh_verify.batch_status import authoritative_status_map from cbb_refresh_verify.batch_status import authoritative_status_map
from .timed_prompt import arm_default
from . import timed_prompt
from cbb_refresh_verify.defaults import DEFAULT_TIMEOUT_SECONDS from cbb_refresh_verify.defaults import DEFAULT_TIMEOUT_SECONDS
from cbb_refresh_verify.network_path import LibraryPathLease, select_library_file from cbb_refresh_verify.network_path import LibraryPathLease, select_library_file
from cbb_refresh_verify.verify_runner import (VerifyRequest, preflight_skip_reason, run_verify, from cbb_refresh_verify.verify_runner import (VerifyRequest, preflight_skip_reason, run_verify,
@@ -1173,21 +1175,21 @@ class MainWindow(QWidget):
from .backup_notice import MANUAL_BACKUP_NOTICE from .backup_notice import MANUAL_BACKUP_NOTICE
if self.busy or not self.loaded_path or self._native_backup_same_library() or not names: if self.busy or not self.loaded_path or self._native_backup_same_library() or not names:
return return
if QMessageBox.question(self, '确认批量校验', if timed_prompt.question(self, '确认批量校验',
f'{MANUAL_BACKUP_NOTICE}\n\n目标库:{self.loaded_path}\n' f'{MANUAL_BACKUP_NOTICE}\n\n目标库:{self.loaded_path}\n'
f'将校验 {len(names)} 个可见非 READY CBB 并保存结果。确认继续?', f'将校验 {len(names)} 个可见非 READY CBB 并保存结果。确认继续?',
QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes: QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.Yes:
self._run(names) self._run(names)
def repair_icdb_all(self): def repair_icdb_all(self):
if self.busy or not self.loaded_path: return if self.busy or not self.loaded_path: return
names = self._maintenance_names() names = self._maintenance_names()
if not names: return if not names: return
answer = QMessageBox.question(self, 'ICDB 批量检查', answer = timed_prompt.question(self, 'ICDB 批量检查',
f'当前中心库:{self.loaded_path}\n\n' f'当前中心库:{self.loaded_path}\n\n'
f'将检查 {len(names)} 个可见非 READY CBB' f'将检查 {len(names)} 个可见非 READY CBB'
f'{"(仅勾选项)" if self.selected_records() else ""}。\n' f'{"(仅勾选项)" if self.selected_records() else ""}。\n'
'仅检查 ICDB 状态,不执行修复或回退。\n\n是否开始?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No) '仅检查 ICDB 状态,不执行修复或回退。\n\n是否开始?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if answer == QMessageBox.Yes: if answer == QMessageBox.Yes:
self._run(names, maintenance=True) self._run(names, maintenance=True)
@@ -1557,6 +1559,8 @@ class MainWindow(QWidget):
if previous is not None: if previous is not None:
previous.close() previous.close()
summary = QMessageBox(self) summary = QMessageBox(self)
summary.setStandardButtons(QMessageBox.Close)
arm_default(summary, summary.button(QMessageBox.Close))
setattr(self, attribute, summary) setattr(self, attribute, summary)
summary.setAttribute(Qt.WA_DeleteOnClose) summary.setAttribute(Qt.WA_DeleteOnClose)
summary.finished.connect(lambda _: self._forget_result_summary(summary)) summary.finished.connect(lambda _: self._forget_result_summary(summary))
@@ -1669,7 +1673,6 @@ class MainWindow(QWidget):
self._resume_batch_action.clicked.connect(self._resume_released_batch) self._resume_batch_action.clicked.connect(self._resume_released_batch)
self._resume_batch_action.setEnabled(False) self._resume_batch_action.setEnabled(False)
if self._reimport_offers: if self._reimport_offers:
self.summary.setStandardButtons(QMessageBox.Close)
self._reimport_summary_action = self.summary.addButton('选择副本恢复…', QMessageBox.ActionRole) self._reimport_summary_action = self.summary.addButton('选择副本恢复…', QMessageBox.ActionRole)
self._reimport_summary_action.clicked.connect(self.reimport_failed) self._reimport_summary_action.clicked.connect(self.reimport_failed)
self._reimport_summary_action.setEnabled(False) # Enabled after the worker finishes. self._reimport_summary_action.setEnabled(False) # Enabled after the worker finishes.
@@ -9,6 +9,7 @@ from PySide6.QtWidgets import (QCheckBox, QDialog, QFileDialog, QHBoxLayout, QLa
from .workers import ServiceWorker from .workers import ServiceWorker
from .backup_notice import MANUAL_BACKUP_NOTICE from .backup_notice import MANUAL_BACKUP_NOTICE
from . import timed_prompt
from ..management import run_management_batch from ..management import run_management_batch
RESULT_LABELS = { RESULT_LABELS = {
@@ -163,10 +164,10 @@ class ManagementDialog(QDialog):
if self.recovery_from: if self.recovery_from:
description = ('将用所选副本替换这些 CBB。操作会先移除原条目,再导入副本;' description = ('将用所选副本替换这些 CBB。操作会先移除原条目,再导入副本;'
'导入失败时需要用备份恢复。请确认副本版本。') '导入失败时需要用备份恢复。请确认副本版本。')
answer = QMessageBox.question(self, '确认管理操作', answer = timed_prompt.question(self, '确认管理操作',
f'{MANUAL_BACKUP_NOTICE}\n{description}\n\n目标库:{self.template.library}\n{preview}\n\n' f'{MANUAL_BACKUP_NOTICE}\n{description}\n\n目标库:{self.template.library}\n{preview}\n\n'
'确认继续执行?', QMessageBox.Yes | QMessageBox.No, '确认继续执行?', QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) QMessageBox.Yes)
if answer != QMessageBox.Yes: if answer != QMessageBox.Yes:
return return
self.busy = True; self.executed = True self.busy = True; self.executed = True
+5 -2
View File
@@ -1,4 +1,5 @@
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
from .timed_prompt import arm_default
class PcbOpenDialog(QMessageBox): class PcbOpenDialog(QMessageBox):
@@ -13,9 +14,11 @@ class PcbOpenDialog(QMessageBox):
self.continue_button = self.addButton('确认无人使用,继续打开', QMessageBox.ActionRole) self.continue_button = self.addButton('确认无人使用,继续打开', QMessageBox.ActionRole)
self.skip_button = self.addButton('跳过本项', QMessageBox.ActionRole) self.skip_button = self.addButton('跳过本项', QMessageBox.ActionRole)
self.cancel_button = self.addButton('取消本批次', QMessageBox.RejectRole) self.cancel_button = self.addButton('取消本批次', QMessageBox.RejectRole)
self.setDefaultButton(self.cancel_button) self.setDefaultButton(self.skip_button)
self.setEscapeButton(self.cancel_button) self.setEscapeButton(self.cancel_button)
self.setModal(True) self.setModal(True)
self.buttonClicked.connect(lambda b: choice.choose('continue' if b is self.continue_button else self.buttonClicked.connect(lambda b: choice.choose('continue' if b is self.continue_button else
'skip' if b is self.skip_button else 'cancel')) 'skip' if b is self.skip_button else 'cancel',
origin=self.property('selectionOrigin') or 'user'))
self.finished.connect(lambda _: choice.choose('cancel')) self.finished.connect(lambda _: choice.choose('cancel'))
arm_default(self, self.skip_button)
@@ -1,5 +1,6 @@
"""Show the native version dates without preselecting a recovery version.""" """Prefer the authorized last manually saved version after a visible countdown."""
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
from .timed_prompt import arm_default
class PcbRestoreDialog(QMessageBox): class PcbRestoreDialog(QMessageBox):
@@ -14,7 +15,7 @@ class PcbRestoreDialog(QMessageBox):
'原生程序检测到上次异常退出,需要选择 PCB 恢复版本。\n' '原生程序检测到上次异常退出,需要选择 PCB 恢复版本。\n'
f'最后手动保存:{manual["date"]}\n自动保存:{auto["date"]}\n\n' f'最后手动保存:{manual["date"]}\n自动保存:{auto["date"]}\n\n'
'选择历史版本可能丢失此版本之后的修改。选择后继续校验、保存和状态确认;恢复版本仍需核对。' '选择历史版本可能丢失此版本之后的修改。选择后继续校验、保存和状态确认;恢复版本仍需核对。'
'\n取消将停止本项并保留原生现场,不自动选取版本。') '\n默认选择最后手动保存;该版本不可用时取消本项。')
self.manual_button = self.addButton(f'最后手动保存({manual["date"]})', QMessageBox.ActionRole) self.manual_button = self.addButton(f'最后手动保存({manual["date"]})', QMessageBox.ActionRole)
self.auto_button = self.addButton(f'自动保存({auto["date"]})', QMessageBox.ActionRole) self.auto_button = self.addButton(f'自动保存({auto["date"]})', QMessageBox.ActionRole)
self.manual_button.setEnabled(manual['enabled']) self.manual_button.setEnabled(manual['enabled'])
@@ -25,7 +26,9 @@ class PcbRestoreDialog(QMessageBox):
self.buttonClicked.connect(self._chosen) self.buttonClicked.connect(self._chosen)
self.finished.connect(lambda _: choice.choose('cancel')) self.finished.connect(lambda _: choice.choose('cancel'))
self.setModal(True) self.setModal(True)
arm_default(self, self.manual_button if manual['enabled'] else self.cancel_button)
def _chosen(self, button): def _chosen(self, button):
self.choice.choose('last_user_saved' if button is self.manual_button else self.choice.choose('last_user_saved' if button is self.manual_button else
'autosave' if button is self.auto_button else 'cancel') 'autosave' if button is self.auto_button else 'cancel',
origin=self.property('selectionOrigin') or 'user')
@@ -7,6 +7,8 @@ from PySide6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPushB
QTableWidget, QTableWidgetItem, QHeaderView, QMessageBox) QTableWidget, QTableWidgetItem, QHeaderView, QMessageBox)
from .workers import ServiceWorker from .workers import ServiceWorker
from .timed_prompt import arm_default
from . import timed_prompt
from ..residual_sessions import force_block_reason, release_targets_complete from ..residual_sessions import force_block_reason, release_targets_complete
@@ -128,6 +130,8 @@ class ResidualReleaseDialog(QDialog):
details.extend(c.get('text', '') for c in window.get('children', []) details.extend(c.get('text', '') for c in window.get('children', [])
if c.get('class') == 'Static') if c.get('class') == 'Static')
box.setDetailedText('\n'.join(details)) box.setDetailedText('\n'.join(details))
box.setStandardButtons(QMessageBox.Close)
arm_default(box, box.button(QMessageBox.Close))
box.show() box.show()
def cancel_native(self): def cancel_native(self):
@@ -136,10 +140,10 @@ class ResidualReleaseDialog(QDialog):
if row < 0: return if row < 0: return
session = self.plan['sessions'][row] session = self.plan['sessions'][row]
if not session.get('cancel_prompt'): return if not session.get('cancel_prompt'): return
answer = QMessageBox.question(self, '请求原生取消', answer = timed_prompt.question(self, '请求原生取消',
f'请求 {session["name"]} (PID {session["pid"]}) 当前显示的取消按钮?\n' f'请求 {session["name"]} (PID {session["pid"]}) 当前显示的取消按钮?\n'
'取消后的工程状态仍需核对;不会强制结束进程。', '取消后的工程状态仍需核对;不会强制结束进程。',
QMessageBox.Yes | QMessageBox.No, QMessageBox.No) QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if answer != QMessageBox.Yes: return if answer != QMessageBox.Yes: return
from cbb_refresh_verify.residual_sessions import request_native_cancel from cbb_refresh_verify.residual_sessions import request_native_cancel
self.before_release.emit(); self.stop.clear() self.before_release.emit(); self.stop.clear()
@@ -187,9 +191,9 @@ class ResidualReleaseDialog(QDialog):
session = self.plan['sessions'][row] session = self.plan['sessions'][row]
prompt = session.get('prompt') prompt = session.get('prompt')
if not prompt: return if not prompt: return
choice = QMessageBox.question(self, '关闭工程前保存', prompt['text']+ choice = timed_prompt.question(self, '关闭工程前保存', prompt['text']+
'\n\n是:保存后关闭;否:放弃未保存更改;取消:保留会话。', '\n\n是:保存后关闭;否:放弃未保存更改;取消:保留会话。',
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Cancel) QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Yes)
code = {QMessageBox.Yes: 6, QMessageBox.No: 7, QMessageBox.Cancel: 2}[choice] code = {QMessageBox.Yes: 6, QMessageBox.No: 7, QMessageBox.Cancel: 2}[choice]
from cbb_refresh_verify.residual_sessions import answer_save_question from cbb_refresh_verify.residual_sessions import answer_save_question
self._start(lambda: answer_save_question(session, code), self._start(lambda: answer_save_question(session, code),
@@ -233,7 +237,7 @@ class ResidualReleaseDialog(QDialog):
targets = [r for r in self.plan['sessions'] if not force_block_reason(r)] targets = [r for r in self.plan['sessions'] if not force_block_reason(r)]
if not targets: return if not targets: return
names = '\n'.join(f'{r.get("project", "")} — {r["name"]} (PID {r["pid"]})' for r in targets) names = '\n'.join(f'{r.get("project", "")} — {r["name"]} (PID {r["pid"]})' for r in targets)
answer = QMessageBox.warning(self, '强制结束客户端', answer = timed_prompt.warning(self, '强制结束客户端',
'仅强制结束以下客户端。客户端中其他已打开工程也会退出;未保存的更改会丢失,正在写入的工程可能需要恢复。' '仅强制结束以下客户端。客户端中其他已打开工程也会退出;未保存的更改会丢失,正在写入的工程可能需要恢复。'
'\n数据库服务器和归属未知的进程不会被强制结束。\n\n'+names+ '\n数据库服务器和归属未知的进程不会被强制结束。\n\n'+names+
'\n\n仍要结束这些进程吗?', QMessageBox.Yes | QMessageBox.Cancel, QMessageBox.Cancel) '\n\n仍要结束这些进程吗?', QMessageBox.Yes | QMessageBox.Cancel, QMessageBox.Cancel)
+96
View File
@@ -0,0 +1,96 @@
"""Visible, one-shot defaults for confirmation prompts in unattended batches."""
from math import ceil
import logging
from PySide6.QtCore import QElapsedTimer, QEvent, QObject, QTimer, Slot
from PySide6.QtWidgets import QMessageBox
DEFAULT_TIMEOUT_MS = 3000
class _Countdown(QObject):
def __init__(self, box, button):
super().__init__(box)
self.box, self.button = box, button
self.label = button.text()
self.duration = DEFAULT_TIMEOUT_MS
self.elapsed = QElapsedTimer()
self.timer = QTimer(self)
self.timer.setInterval(50)
self.timer.timeout.connect(self.tick)
self.done = False
box.setDefaultButton(button)
box.buttonClicked.connect(self.stop)
box.finished.connect(self.stop)
box.installEventFilter(self)
if box.isVisible():
self.start()
@Slot()
def start(self):
if self.done:
return
self.elapsed.start()
self.timer.start()
self.button.setText(f'{self.label}({ceil(self.duration / 1000)} 秒)')
def eventFilter(self, watched, event):
if event.type() == QEvent.Show:
self.start()
elif event.type() in (QEvent.Hide, QEvent.Close):
self.timer.stop()
return False
@Slot()
def stop(self):
self.done = True
self.timer.stop()
self.button.setText(self.label)
@Slot()
def tick(self):
if self.done or not self.box.isVisible():
self.timer.stop()
return
remaining = self.duration - self.elapsed.elapsed()
if remaining > 0:
self.button.setText(f'{self.label}({ceil(remaining / 1000)} 秒)')
return
self.timer.stop()
if not self.button.isEnabled():
self.box.setProperty('selectionOrigin', 'timeout_default')
self.box.reject()
return
self.box.setProperty('selectionOrigin', 'timeout_default')
self.button.click()
def arm_default(box, button):
countdown = _Countdown(box, button)
box._default_countdown = countdown
return countdown
def _ask(icon, parent, title, text, buttons, default):
box = QMessageBox(icon, title, text, buttons, parent)
arm_default(box, box.button(default))
try:
result = QMessageBox.StandardButton(box.exec())
owner = parent
while owner is not None and getattr(owner, 'logging_context', None) is None:
owner = owner.parentWidget()
context = getattr(owner, 'logging_context', None)
logger = context.logger if context is not None else logging.getLogger('cbb_refresh_verify')
logger.info('prompt_decision title=%s result=%s origin=%s', title, result.name,
box.property('selectionOrigin') or 'user')
return result
finally:
box.deleteLater()
def question(parent, title, text, buttons, default):
return _ask(QMessageBox.Question, parent, title, text, buttons, default)
def warning(parent, title, text, buttons, default):
return _ask(QMessageBox.Warning, parent, title, text, buttons, default)
@@ -1,4 +1,5 @@
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
from .timed_prompt import arm_default
class WriteOwnerDialog(QMessageBox): class WriteOwnerDialog(QMessageBox):
@@ -15,9 +16,11 @@ class WriteOwnerDialog(QMessageBox):
self.continue_button = self.addButton('已确认未使用此库,继续', QMessageBox.ActionRole) self.continue_button = self.addButton('已确认未使用此库,继续', QMessageBox.ActionRole)
self.skip_button = self.addButton('跳过本项', QMessageBox.ActionRole) self.skip_button = self.addButton('跳过本项', QMessageBox.ActionRole)
self.cancel_button = self.addButton('取消本批次', QMessageBox.RejectRole) self.cancel_button = self.addButton('取消本批次', QMessageBox.RejectRole)
self.setDefaultButton(self.cancel_button) self.setDefaultButton(self.skip_button)
self.setEscapeButton(self.cancel_button) self.setEscapeButton(self.cancel_button)
self.setModal(True) self.setModal(True)
self.buttonClicked.connect(lambda b: choice.choose('continue' if b is self.continue_button else self.buttonClicked.connect(lambda b: choice.choose('continue' if b is self.continue_button else
'skip' if b is self.skip_button else 'cancel')) 'skip' if b is self.skip_button else 'cancel',
origin=self.property('selectionOrigin') or 'user'))
self.finished.connect(lambda _: choice.choose('cancel')) self.finished.connect(lambda _: choice.choose('cancel'))
arm_default(self, self.skip_button)
+4 -1
View File
@@ -63,7 +63,9 @@ class WriteAdmission:
if decision != 'continue': if decision != 'continue':
if decision == 'cancel' and self.stop is not None: if decision == 'cancel' and self.stop is not None:
self.stop.set() self.stop.set()
raise WriteAdmissionDeclined(decision) detail = ('确认等待超时默认跳过本项,未授予未知进程写入许可。'
if decision == 'skip' and choice.decision_origin == 'timeout_default' else None)
raise WriteAdmissionDeclined(decision, detail)
current, _ = self._identities(owners) current, _ = self._identities(owners)
if not set(current).issubset(identities): if not set(current).issubset(identities):
raise ValueError('TARGET_NATIVE_OWNER_UNCONFIRMED: 确认期间进程身份已变化,请重新检查。') raise ValueError('TARGET_NATIVE_OWNER_UNCONFIRMED: 确认期间进程身份已变化,请重新检查。')
@@ -73,5 +75,6 @@ class WriteAdmission:
_write_json(root/('write-owner-consent-'+uuid4().hex+'.json'), dict( _write_json(root/('write-owner-consent-'+uuid4().hex+'.json'), dict(
intent='user_confirmed_unknown_clients_do_not_use_target_library', library=str(Path(library).resolve()), intent='user_confirmed_unknown_clients_do_not_use_target_library', library=str(Path(library).resolve()),
block=block, scope='current_batch_library', owners=rows, choice='continue', block=block, scope='current_batch_library', owners=rows, choice='continue',
decision_origin=choice.decision_origin,
proves_native_ownership=False, requires_fresh_resource_checks=True)) proves_native_ownership=False, requires_fresh_resource_checks=True))
self._grants.setdefault(key, set()).update(current) self._grants.setdefault(key, set()).update(current)
+2 -2
View File
@@ -152,7 +152,7 @@ def test_main_check_buttons_have_real_confirm_and_cancel_paths(controls, qtbot,
assert details is not None assert details is not None
press(qtbot, details) press(qtbot, details)
assert summary.findChild(QTextEdit).isVisible() assert summary.findChild(QTextEdit).isVisible()
press(qtbot, summary.button(QMessageBox.Ok)) press(qtbot, summary.button(QMessageBox.Close))
assert not isValid(summary) or not summary.isVisible() assert not isValid(summary) or not summary.isVisible()
@@ -411,7 +411,7 @@ def test_residual_refresh_details_confirm_and_close(residual, qtbot):
expand = next(b for b in details.findChildren(QPushButton) if 'Details' in b.text()) expand = next(b for b in details.findChildren(QPushButton) if 'Details' in b.text())
press(qtbot, expand) press(qtbot, expand)
assert details.findChild(QTextEdit).isVisible() assert details.findChild(QTextEdit).isVisible()
press(qtbot, details.button(QMessageBox.Ok)) press(qtbot, details.button(QMessageBox.Close))
press(qtbot, d.confirm_button) press(qtbot, d.confirm_button)
qtbot.waitUntil(lambda: not d.busy) qtbot.waitUntil(lambda: not d.busy)
assert len(residual.releases) == 1 and residual.releases[0]['force'] is False assert len(residual.releases) == 1 and residual.releases[0]['force'] is False
+2 -1
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from pathlib import Path from pathlib import Path
from threading import Event from threading import Event
@@ -8,7 +9,7 @@ import pytest
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def accept_manual_backup_reminder(monkeypatch): def accept_manual_backup_reminder(monkeypatch):
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
def test_backup_dialog_requires_a_project_and_passes_selected_target(qtbot, tmp_path): def test_backup_dialog_requires_a_project_and_passes_selected_target(qtbot, tmp_path):
+2 -1
View File
@@ -1,4 +1,5 @@
"""Batch ICDB checks open diagnostically without dispatching Repair.""" """Batch ICDB checks open diagnostically without dispatching Repair."""
from cbb_refresh_verify.ui import timed_prompt
from dataclasses import replace from dataclasses import replace
import json import json
@@ -93,7 +94,7 @@ def test_ui_check_summary_reports_findings_and_never_claims_repair(qtbot, tmp_pa
verifier=lambda req: (requests.append(req) or VerifyResult('FAIL', verifier=lambda req: (requests.append(req) or VerifyResult('FAIL',
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')), error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')),
status_refresher=lambda names, _: {name: 'PENDING' for name in names}) status_refresher=lambda names, _: {name: 'PENDING' for name in names})
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (prompts.append(a[2]) or QMessageBox.Yes)) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: (prompts.append(a[2]) or QMessageBox.Yes))
window.search_edit.setText('Beta') window.search_edit.setText('Beta')
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window._icdb_active()) window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window._icdb_active())
assert requests[0].maintenance and not requests[0].auto_repair assert requests[0].maintenance and not requests[0].auto_repair
+2 -1
View File
@@ -1,4 +1,5 @@
"""Normal imports must not depend on optional schematic export tools.""" """Normal imports must not depend on optional schematic export tools."""
from cbb_refresh_verify.ui import timed_prompt
from dataclasses import replace from dataclasses import replace
import json import json
@@ -57,7 +58,7 @@ def test_bad_source_row_does_not_prevent_valid_rows_from_starting(qtbot, tmp_pat
r.auto_verify, 'complete', 'UPLOAD_FAILED' if r.name == 'Missing' else 'UPLOADED', r.auto_verify, 'complete', 'UPLOAD_FAILED' if r.name == 'Missing' else 'UPLOADED',
True, 'per-item result') for r in requests] True, 'per-item result') for r in requests]
dialog = ManagementDialog(rows, runner=runner); qtbot.addWidget(dialog) dialog = ManagementDialog(rows, runner=runner); qtbot.addWidget(dialog)
monkeypatch.setattr(QMessageBox, 'question', lambda *_a, **_kw: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *_a, **_kw: QMessageBox.Yes)
dialog.execute_button.click() dialog.execute_button.click()
qtbot.waitUntil(lambda: bool(seen) and not dialog.busy) qtbot.waitUntil(lambda: bool(seen) and not dialog.busy)
assert [r.name for r in seen] == ['Missing', 'Good'] assert [r.name for r in seen] == ['Missing', 'Good']
+5 -4
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
import json import json
from pathlib import Path from pathlib import Path
@@ -16,9 +17,9 @@ def test_only_confirmed_maintenance_sets_explicit_flag(qtbot, tmp_path, monkeypa
window.search_edit.setText('Beta') window.search_edit.setText('Beta')
window.verify_all(); qtbot.waitUntil(lambda: not window.busy) window.verify_all(); qtbot.waitUntil(lambda: not window.busy)
assert calls and calls[-1].maintenance is False assert calls and calls[-1].maintenance is False
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.No) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.No)
window.repair_icdb_all(); assert len(calls) == 1 window.repair_icdb_all(); assert len(calls) == 1
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
window.repair_icdb_all(); qtbot.waitUntil(lambda: not window._icdb_active()) window.repair_icdb_all(); qtbot.waitUntil(lambda: not window._icdb_active())
assert len(calls) == 2 and calls[-1].maintenance is True assert len(calls) == 2 and calls[-1].maintenance is True
@@ -56,7 +57,7 @@ def test_old_checkpoint_does_not_force_maintenance_or_disable_verify(qtbot, tmp_
window.select_visible_button.click() window.select_visible_button.click()
assert window.icdb_repair_button.isEnabled() assert window.icdb_repair_button.isEnabled()
assert window.batch_button.isEnabled() and window.selected_batch_button.isEnabled() assert window.batch_button.isEnabled() and window.selected_batch_button.isEnabled()
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
window.verify_selected(); qtbot.waitUntil(lambda: not window.busy) window.verify_selected(); qtbot.waitUntil(lambda: not window.busy)
assert len(calls) == 1 and calls[0].maintenance is False assert len(calls) == 1 and calls[0].maintenance is False
assert window.selected_batch_button.isEnabled() assert window.selected_batch_button.isEnabled()
@@ -102,7 +103,7 @@ def test_open_check_preserves_verify_state_without_starting_an_extra_catalog_rea
blocker_path(library).unlink() # Simulate normal cleanup at the injected boundary. blocker_path(library).unlink() # Simulate normal cleanup at the injected boundary.
return VerifyResult('CHECKED') return VerifyResult('CHECKED')
monkeypatch.setattr(ui, 'preflight_skip_reason', lambda *a: None) monkeypatch.setattr(ui, 'preflight_skip_reason', lambda *a: None)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
window = MainWindow(reader=reader, verifier=verify, data_root=tmp_path/'data', window = MainWindow(reader=reader, verifier=verify, data_root=tmp_path/'data',
status_refresher=lambda *a: pytest.fail('An open check must not start a second native status read')) status_refresher=lambda *a: pytest.fail('An open check must not start a second native status read'))
qtbot.addWidget(window) qtbot.addWidget(window)
+3 -2
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from dataclasses import replace from dataclasses import replace
from pathlib import Path from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
@@ -39,10 +40,10 @@ def test_management_dialog_preview_confirmation_and_result_status(qtbot, tmp_pat
False, 'complete', 'REMOVED', True, 'removed', tmp_path/'checkpoint.json')] False, 'complete', 'REMOVED', True, 'removed', tmp_path/'checkpoint.json')]
dialog = ManagementDialog(requests, runner=runner) dialog = ManagementDialog(requests, runner=runner)
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (confirmations.append(a[2]) or QMessageBox.No)) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: (confirmations.append(a[2]) or QMessageBox.No))
dialog.execute_button.click() dialog.execute_button.click()
assert not calls and 'Block' in confirmations[0] and '手动备份' in confirmations[0] assert not calls and 'Block' in confirmations[0] and '手动备份' in confirmations[0]
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
dialog.execute_button.click() dialog.execute_button.click()
qtbot.waitUntil(lambda: not dialog.busy) qtbot.waitUntil(lambda: not dialog.busy)
assert len(calls) == 1 and '已移除' in dialog.status_label.text() assert len(calls) == 1 and '已移除' in dialog.status_label.text()
+4 -3
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from pathlib import Path from pathlib import Path
import pytest import pytest
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
@@ -9,7 +10,7 @@ def test_management_prompts_for_manual_backup_and_cancel_starts_nothing(qtbot, t
from cbb_refresh_verify.ui.management_dialog import ManagementDialog from cbb_refresh_verify.ui.management_dialog import ManagementDialog
source = tmp_path/'Block.prj'; source.touch() source = tmp_path/'Block.prj'; source.touch()
seen, calls = [], [] seen, calls = [], []
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No)) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
dialog = ManagementDialog([ManagementRequest(operation, tmp_path/'lib.lmc', 'Block', source=source)], dialog = ManagementDialog([ManagementRequest(operation, tmp_path/'lib.lmc', 'Block', source=source)],
runner=lambda *a, **k: calls.append(a)) runner=lambda *a, **k: calls.append(a))
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
@@ -30,7 +31,7 @@ def test_batch_prompts_once_for_manual_backup_and_cancel_does_not_start(qtbot, t
window.select_visible_button.click() window.select_visible_button.click()
seen, calls = [], [] seen, calls = [], []
monkeypatch.setattr(window, '_run', lambda *a, **k: calls.append(a)) monkeypatch.setattr(window, '_run', lambda *a, **k: calls.append(a))
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No)) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
getattr(window, action)() getattr(window, action)()
assert not calls assert not calls
assert len(seen) == 1 and '手动备份' in seen[0] and '不会自动备份' in seen[0] assert len(seen) == 1 and '手动备份' in seen[0] and '不会自动备份' in seen[0]
@@ -41,7 +42,7 @@ def test_restore_prompts_for_manual_backup_before_starting_worker(qtbot, tmp_pat
from cbb_refresh_verify.ui.backup_recovery_dialog import BackupRecoveryDialog from cbb_refresh_verify.ui.backup_recovery_dialog import BackupRecoveryDialog
calls, seen = [], [] calls, seen = [], []
source = tmp_path/'Block.prj'; source.touch() source = tmp_path/'Block.prj'; source.touch()
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No)) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
dialog = BackupRecoveryDialog(['Block'], lambda n: VerifyRequest(tmp_path/'lib.lmc', n, tmp_path/'out'), dialog = BackupRecoveryDialog(['Block'], lambda n: VerifyRequest(tmp_path/'lib.lmc', n, tmp_path/'out'),
recoverer=lambda *a, **k: (calls.append(a) or VerifyResult('PASS'))) recoverer=lambda *a, **k: (calls.append(a) or VerifyResult('PASS')))
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
+1 -1
View File
@@ -47,7 +47,7 @@ def test_explicit_open_dialog_defaults_to_cancel(qtbot):
from cbb_refresh_verify.ui.pcb_open_dialog import PcbOpenDialog from cbb_refresh_verify.ui.pcb_open_dialog import PcbOpenDialog
choice=OpenChoice('A','lib.lmc') choice=OpenChoice('A','lib.lmc')
dialog=PcbOpenDialog(choice);qtbot.addWidget(dialog) dialog=PcbOpenDialog(choice);qtbot.addWidget(dialog)
assert dialog.defaultButton() is dialog.cancel_button assert dialog.defaultButton() is dialog.skip_button
dialog.skip_button.click() dialog.skip_button.click()
assert choice.decision=='skip' assert choice.decision=='skip'
+3 -2
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from dataclasses import replace from dataclasses import replace
from pathlib import Path from pathlib import Path
from threading import Event from threading import Event
@@ -62,7 +63,7 @@ def test_declining_reimport_confirmation_does_not_check_release_or_write(qtbot,
dialog.add_sources([source]) dialog.add_sources([source])
monkeypatch.setattr(locks, 'release_retained_library', lambda *a: pytest.fail('unconfirmed release')) monkeypatch.setattr(locks, 'release_retained_library', lambda *a: pytest.fail('unconfirmed release'))
confirmations = [] confirmations = []
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **kw: monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw:
confirmations.append(a[2]) or QMessageBox.No) confirmations.append(a[2]) or QMessageBox.No)
dialog.execute_button.click() dialog.execute_button.click()
assert not dialog.busy and not dialog.executed assert not dialog.busy and not dialog.executed
@@ -179,7 +180,7 @@ def test_recovery_uses_background_release_then_existing_management(qtbot, tmp_pa
return [ManagementResult('update', req.library, req.name, req.partition, req.source, return [ManagementResult('update', req.library, req.name, req.partition, req.source,
True, 'complete', 'UPLOADED_VERIFIED', True)] True, 'complete', 'UPLOADED_VERIFIED', True)]
monkeypatch.setattr(management, 'run_management_batch', run) monkeypatch.setattr(management, 'run_management_batch', run)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **kw: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw: QMessageBox.Yes)
dialog = ManagementDialog([req], recovery_from={'Block': 'old.json'}) dialog = ManagementDialog([req], recovery_from={'Block': 'old.json'})
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
ticks = [] ticks = []
+4 -3
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from pathlib import Path from pathlib import Path
from PySide6.QtCore import Qt from PySide6.QtCore import Qt
@@ -93,10 +94,10 @@ def test_force_close_is_explicit_and_cancel_does_not_release(qtbot, tmp_path, mo
dialog = ResidualReleaseDialog(tmp_path/'lib.lmc', tmp_path/'evidence') dialog = ResidualReleaseDialog(tmp_path/'lib.lmc', tmp_path/'evidence')
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
qtbot.waitUntil(lambda: not dialog.busy) qtbot.waitUntil(lambda: not dialog.busy)
monkeypatch.setattr(QMessageBox, 'warning', lambda *a: QMessageBox.Cancel) monkeypatch.setattr(timed_prompt, 'warning', lambda *a: QMessageBox.Cancel)
dialog.force_button.click() dialog.force_button.click()
assert not calls assert not calls
monkeypatch.setattr(QMessageBox, 'warning', lambda *a: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'warning', lambda *a: QMessageBox.Yes)
dialog.force_button.click() dialog.force_button.click()
qtbot.waitUntil(lambda: not dialog.busy) qtbot.waitUntil(lambda: not dialog.busy)
assert calls == [True] assert calls == [True]
@@ -115,7 +116,7 @@ def test_force_confirmation_excludes_shared_servers(qtbot, tmp_path, monkeypatch
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
qtbot.waitUntil(lambda: not dialog.busy) qtbot.waitUntil(lambda: not dialog.busy)
messages = [] messages = []
monkeypatch.setattr(QMessageBox, 'warning', lambda parent, title, text, *args: monkeypatch.setattr(timed_prompt, 'warning', lambda parent, title, text, *args:
messages.append(text) or QMessageBox.Cancel) messages.append(text) or QMessageBox.Cancel)
dialog.force_button.click() dialog.force_button.click()
assert len(messages) == 1 assert len(messages) == 1
+2 -1
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
from pathlib import Path from pathlib import Path
from threading import Event from threading import Event
@@ -125,7 +126,7 @@ def test_management_wait_shows_same_block_and_emits_release_target(qtbot, tmp_pa
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
library = tmp_path/'lib.lmc' library = tmp_path/'lib.lmc'
retain(monkeypatch, library) retain(monkeypatch, library)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **kw: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw: QMessageBox.Yes)
dialog = ManagementDialog([ManagementRequest('remove', library, 'A')], runner=lambda *a, **kw: []) dialog = ManagementDialog([ManagementRequest('remove', library, 'A')], runner=lambda *a, **kw: [])
dialog.native_queue = NativeQueue() dialog.native_queue = NativeQueue()
qtbot.addWidget(dialog); dialog.show() qtbot.addWidget(dialog); dialog.show()
+1 -1
View File
@@ -117,7 +117,7 @@ def test_write_confirmation_dialog_defaults_cancel_and_cannot_overwrite_choice(q
from cbb_refresh_verify.ui.write_owner_dialog import WriteOwnerDialog from cbb_refresh_verify.ui.write_owner_dialog import WriteOwnerDialog
choice=WriteOwnerChoice('Block','target.lmc',[dict(pid=12,name='viewdraw.exe',image='viewdraw.exe')]) choice=WriteOwnerChoice('Block','target.lmc',[dict(pid=12,name='viewdraw.exe',image='viewdraw.exe')])
dialog=WriteOwnerDialog(choice);qtbot.addWidget(dialog) dialog=WriteOwnerDialog(choice);qtbot.addWidget(dialog)
assert dialog.defaultButton() is dialog.cancel_button assert dialog.defaultButton() is dialog.skip_button
dialog.skip_button.click();dialog.reject() dialog.skip_button.click();dialog.reject()
assert choice.decision=='skip' assert choice.decision=='skip'
+4 -3
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
import json import json
from contextlib import nullcontext from contextlib import nullcontext
from pathlib import Path from pathlib import Path
@@ -180,9 +181,9 @@ def test_ui_native_cancel_is_explicit_and_details_are_readable(qtbot, tmp_path,
assert 'Backing up project' in dialog.native_details.detailedText() assert 'Backing up project' in dialog.native_details.detailedText()
assert 'CbbRepair_A' in dialog.native_details.detailedText() assert 'CbbRepair_A' in dialog.native_details.detailedText()
dialog.native_details.close() dialog.native_details.close()
monkeypatch.setattr(QMessageBox,'question',lambda *a:QMessageBox.No) monkeypatch.setattr(timed_prompt,'question',lambda *a:QMessageBox.No)
dialog.cancel_native_button.click();assert calls==[] dialog.cancel_native_button.click();assert calls==[]
monkeypatch.setattr(QMessageBox,'question',lambda *a:QMessageBox.Yes) monkeypatch.setattr(timed_prompt,'question',lambda *a:QMessageBox.Yes)
dialog.cancel_native_button.click();qtbot.waitUntil(lambda:not dialog.busy) dialog.cancel_native_button.click();qtbot.waitUntil(lambda:not dialog.busy)
assert calls==[process] assert calls==[process]
@@ -245,7 +246,7 @@ def test_native_cancel_completion_propagates_actual_release_to_parent(qtbot,tmp_
proof={'status':'RELEASE_CONFIRMED','library':str(library)} proof={'status':'RELEASE_CONFIRMED','library':str(library)}
monkeypatch.setattr(residual_sessions,'request_native_cancel',lambda *a,**kw: monkeypatch.setattr(residual_sessions,'request_native_cancel',lambda *a,**kw:
{'status':'RELEASE_CONFIRMED','sessions':[{**process,'release_status':'RELEASED'}],'proof':proof}) {'status':'RELEASE_CONFIRMED','sessions':[{**process,'release_status':'RELEASED'}],'proof':proof})
monkeypatch.setattr(QMessageBox,'question',lambda *a:QMessageBox.Yes) monkeypatch.setattr(timed_prompt,'question',lambda *a:QMessageBox.Yes)
dialog=ResidualReleaseDialog(library,tmp_path/'evidence');qtbot.addWidget(dialog) dialog=ResidualReleaseDialog(library,tmp_path/'evidence');qtbot.addWidget(dialog)
released=[];dialog.released.connect(released.append) released=[];dialog.released.connect(released.append)
qtbot.waitUntil(lambda:not dialog.busy) qtbot.waitUntil(lambda:not dialog.busy)
+6 -5
View File
@@ -1,3 +1,4 @@
from cbb_refresh_verify.ui import timed_prompt
import os import os
import pytest import pytest
from pathlib import Path from pathlib import Path
@@ -26,7 +27,7 @@ def fake_reader(_): return LibraryReadResult((CbbRecord('CBB1','Reusable Blocks'
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def isolate_authoritative_native_refresh(monkeypatch): def isolate_authoritative_native_refresh(monkeypatch):
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
# Production refresh crosses the native Mentor boundary; these are UI tests. # Production refresh crosses the native Mentor boundary; these are UI tests.
monkeypatch.setattr('cbb_refresh_verify.ui.main_window.authoritative_status_map', monkeypatch.setattr('cbb_refresh_verify.ui.main_window.authoritative_status_map',
lambda names, *_: {name: 'READY' for name in names}) lambda names, *_: {name: 'READY' for name in names})
@@ -42,10 +43,10 @@ def test_global_icdb_action_confirms_and_excludes_ready_rows(qtbot, tmp_path, mo
qtbot.addWidget(window) qtbot.addWidget(window)
window.lmc_edit.setText('lib.lmc'); window.load_library() window.lmc_edit.setText('lib.lmc'); window.load_library()
qtbot.waitUntil(lambda: not window.busy) qtbot.waitUntil(lambda: not window.busy)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.No) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.No)
window.icdb_repair_button.click() window.icdb_repair_button.click()
assert calls == [] assert calls == []
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
window.icdb_repair_button.click() window.icdb_repair_button.click()
qtbot.waitUntil(lambda: not window._icdb_active()) qtbot.waitUntil(lambda: not window._icdb_active())
assert calls == ['PENDING'] assert calls == ['PENDING']
@@ -70,7 +71,7 @@ def test_global_icdb_failure_preserves_untargeted_ready_and_stops_queue(qtbot, t
qtbot.addWidget(window) qtbot.addWidget(window)
window.lmc_edit.setText('lib.lmc'); window.load_library() window.lmc_edit.setText('lib.lmc'); window.load_library()
qtbot.waitUntil(lambda: not window.busy) qtbot.waitUntil(lambda: not window.busy)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
window.icdb_repair_button.click() window.icdb_repair_button.click()
qtbot.waitUntil(lambda: not window._icdb_active()) qtbot.waitUntil(lambda: not window._icdb_active())
assert calls == ['B'] assert calls == ['B']
@@ -84,7 +85,7 @@ def test_global_icdb_progress_and_check_summary(qtbot, tmp_path, monkeypatch):
def confirm(*args, **kwargs): def confirm(*args, **kwargs):
confirmations.append(args[2]) confirmations.append(args[2])
return QMessageBox.Yes return QMessageBox.Yes
monkeypatch.setattr(QMessageBox, 'question', confirm) monkeypatch.setattr(timed_prompt, 'question', confirm)
window = MainWindow(reader=fake_reader, data_root=tmp_path, window = MainWindow(reader=fake_reader, data_root=tmp_path,
verifier=lambda _: VerifyResult('FAIL', safe_to_continue=False, recovery_attempts=( verifier=lambda _: VerifyResult('FAIL', safe_to_continue=False, recovery_attempts=(
{'status': 'RESTORED_REVIEW_REQUIRED', 'detail': 'restored old backup'},))) {'status': 'RESTORED_REVIEW_REQUIRED', 'detail': 'restored old backup'},)))
+4 -3
View File
@@ -1,4 +1,5 @@
"""Local catalog scope and authoritative status refresh regression tests.""" """Local catalog scope and authoritative status refresh regression tests."""
from cbb_refresh_verify.ui import timed_prompt
import json import json
import time import time
from threading import Event from threading import Event
@@ -24,7 +25,7 @@ MIXED = (
def load_window(qtbot, tmp_path, monkeypatch, records=MIXED, **kwargs): def load_window(qtbot, tmp_path, monkeypatch, records=MIXED, **kwargs):
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **k: QMessageBox.Yes)
import cbb_refresh_verify.ui.main_window as ui import cbb_refresh_verify.ui.main_window as ui
monkeypatch.setattr(ui, 'preflight_skip_reason', monkeypatch.setattr(ui, 'preflight_skip_reason',
lambda _, name: 'missing project' if name == 'Missing' else None) lambda _, name: 'missing project' if name == 'Missing' else None)
@@ -102,7 +103,7 @@ def test_maintenance_confirmation_progress_and_report_use_visible_checked_subset
status_refresher=refresh) status_refresher=refresh)
window.search_edit.setText('analog') window.search_edit.setText('analog')
window.cbb_table.item(3, 0).setCheckState(Qt.Checked) window.cbb_table.item(3, 0).setCheckState(Qt.Checked)
monkeypatch.setattr(QMessageBox, 'question', lambda *args, **_: ( monkeypatch.setattr(timed_prompt, 'question', lambda *args, **_: (
confirmations.append(args[2]) or QMessageBox.Yes)) confirmations.append(args[2]) or QMessageBox.Yes))
window.repair_icdb_all() window.repair_icdb_all()
qtbot.waitUntil(lambda: not window._icdb_active()) qtbot.waitUntil(lambda: not window._icdb_active())
@@ -126,7 +127,7 @@ def test_maintenance_defaults_to_visible_eligible_and_ready_only_checks_do_not_f
window = load_window(qtbot, tmp_path, monkeypatch, window = load_window(qtbot, tmp_path, monkeypatch,
verifier=lambda req: (calls.append(req.block_name) or VerifyResult('PASS')), verifier=lambda req: (calls.append(req.block_name) or VerifyResult('PASS')),
status_refresher=lambda targets, _: {name: 'PENDING' for name in targets}) status_refresher=lambda targets, _: {name: 'PENDING' for name in targets})
monkeypatch.setattr(QMessageBox, 'question', lambda *_, **__: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *_, **__: QMessageBox.Yes)
window.cbb_table.item(0, 0).setCheckState(Qt.Checked) window.cbb_table.item(0, 0).setCheckState(Qt.Checked)
window.repair_icdb_all() window.repair_icdb_all()
assert not window.busy and calls == [] assert not window.busy and calls == []
+168
View File
@@ -0,0 +1,168 @@
import pytest
from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QMessageBox
def restore_choice(*, manual=True):
from cbb_refresh_verify.pcb_restore_prompt import RestoreChoice
return RestoreChoice('Block', 'library.lmc', [
dict(kind='last_user_saved', date='2026/9/24 23:06', enabled=manual),
dict(kind='autosave', date='2026/9/24 23:06', enabled=True)])
@pytest.mark.parametrize('kind,decision', [('open', 'skip'), ('owner', 'skip'),
('version', 'last_user_saved')])
def test_native_choice_finishes_in_three_seconds_without_an_operator(qtbot, kind, decision):
from cbb_refresh_verify.pcb_open_consent import OpenChoice
from cbb_refresh_verify.ui.pcb_open_dialog import PcbOpenDialog
from cbb_refresh_verify.ui.pcb_restore_dialog import PcbRestoreDialog
from cbb_refresh_verify.ui.write_owner_dialog import WriteOwnerDialog
from cbb_refresh_verify.write_admission import WriteOwnerChoice
if kind == 'open':
choice = OpenChoice('Block', 'library.lmc')
dialog = PcbOpenDialog(choice)
elif kind == 'owner':
choice = WriteOwnerChoice('Block', 'library.lmc', [
dict(pid=12, name='viewdraw.exe', image='viewdraw.exe')])
dialog = WriteOwnerDialog(choice)
else:
choice = restore_choice()
dialog = PcbRestoreDialog(choice)
qtbot.addWidget(dialog)
dialog.show()
qtbot.wait(3200)
assert choice.decision == decision
assert choice.decision_origin == 'timeout_default'
assert not dialog.isVisible()
def test_manual_selection_cancels_the_pending_default(qtbot, monkeypatch):
from cbb_refresh_verify.ui import timed_prompt
from cbb_refresh_verify.ui.pcb_restore_dialog import PcbRestoreDialog
monkeypatch.setattr(timed_prompt, 'DEFAULT_TIMEOUT_MS', 100)
choice = restore_choice()
dialog = PcbRestoreDialog(choice)
qtbot.addWidget(dialog)
dialog.show()
dialog.auto_button.click()
qtbot.wait(200)
assert choice.decision == 'autosave'
assert choice.decision_origin == 'user'
def test_unavailable_preferred_version_never_clicks_disabled_or_other_version(qtbot, monkeypatch):
from cbb_refresh_verify.ui import timed_prompt
from cbb_refresh_verify.ui.pcb_restore_dialog import PcbRestoreDialog
monkeypatch.setattr(timed_prompt, 'DEFAULT_TIMEOUT_MS', 100)
choice = restore_choice(manual=False)
dialog = PcbRestoreDialog(choice)
qtbot.addWidget(dialog)
dialog.show()
qtbot.waitUntil(lambda: choice.decision is not None)
assert choice.decision == 'cancel'
assert choice.decision_origin == 'timeout_default'
@pytest.mark.parametrize('default', [QMessageBox.Yes, QMessageBox.Cancel])
def test_question_runs_its_explicit_default_without_mouse_input(qtbot, monkeypatch, default):
from cbb_refresh_verify.ui import timed_prompt
monkeypatch.setattr(timed_prompt, 'DEFAULT_TIMEOUT_MS', 100)
result = timed_prompt.question(None, 'Timed fixture', 'Choose',
QMessageBox.Yes | QMessageBox.Cancel, default)
assert result == default
def test_manual_question_answer_wins_before_timeout(qtbot, monkeypatch):
from cbb_refresh_verify.ui import timed_prompt
monkeypatch.setattr(timed_prompt, 'DEFAULT_TIMEOUT_MS', 200)
def answer():
from PySide6.QtWidgets import QApplication
for box in QApplication.topLevelWidgets():
if isinstance(box, QMessageBox) and box.windowTitle() == 'Manual fixture':
box.button(QMessageBox.No).click()
QTimer.singleShot(50, answer)
assert timed_prompt.question(None, 'Manual fixture', 'Choose',
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.No
qtbot.wait(250)
def test_hidden_or_closed_notifications_never_execute_later(qtbot, monkeypatch):
from cbb_refresh_verify.ui import timed_prompt
monkeypatch.setattr(timed_prompt, 'DEFAULT_TIMEOUT_MS', 100)
box = QMessageBox()
qtbot.addWidget(box)
box.setStandardButtons(QMessageBox.Close)
clicks = []
box.buttonClicked.connect(lambda _: clicks.append(True))
timed_prompt.arm_default(box, box.button(QMessageBox.Close))
box.show()
box.hide()
qtbot.wait(200)
assert not clicks
box.show()
qtbot.waitUntil(lambda: bool(clicks))
qtbot.wait(200)
assert clicks == [True]
def test_timeout_skip_does_not_grant_unknown_clients_or_stop_the_batch(tmp_path, monkeypatch):
from threading import Event
from cbb_refresh_verify.write_admission import WriteAdmission, WriteAdmissionDeclined
monkeypatch.setattr('cbb_refresh_verify.write_admission.process_identity', lambda pid: dict(
pid=pid, created_handle='one', image='viewdraw.exe', owner_sid='user', session_id=1))
owners = [dict(pid=12, name='viewdraw.exe', executable='viewdraw.exe')]
stop = Event()
admission = WriteAdmission(stop=stop, prompt=lambda c: c.choose('skip', origin='timeout_default'))
with pytest.raises(WriteAdmissionDeclined, match='超时默认'):
admission.confirm(tmp_path/'library.lmc', owners, evidence=tmp_path/'evidence', block='Block')
assert not stop.is_set()
assert not admission.confirmed(tmp_path/'library.lmc', owners)
def test_recorded_pcb_open_choice_distinguishes_timeout_from_user(tmp_path, monkeypatch):
from contextlib import nullcontext
from types import SimpleNamespace
import json
from test_post_repair_consent import snapshot
from cbb_refresh_verify import pcb_open_consent as consent
monkeypatch.setattr(consent, 'validate_owner', lambda *_: {'target': 'owned'})
monkeypatch.setattr(consent, 'resource_guard', lambda *_: nullcontext())
controller = consent.OpenController(dict(root=str(tmp_path), block_name='Block',
lmc_file='library.lmc', project='Block.prj', pcb='Block.pcb', desktop='CbbVerify_test'))
shown = []
options = dict(target_pid=20, launcher_pid=10, worker_pid=5, show=shown.append,
perform=lambda *_: SimpleNamespace(error_code='', accepted_controls=(7,), detail='', channel='win32_button_click'))
controller.handle(snapshot(), (snapshot(),), **options)
shown[0].choose('skip', origin='timeout_default')
result = controller.handle(snapshot(), (snapshot(),), **options)
assert result.error_code == 'PCB_OPEN_SKIPPED'
record = json.loads((tmp_path/'pcb-open-user-choice.json').read_text('utf-8'))
assert record['decision_origin'] == 'timeout_default'
@pytest.mark.parametrize('decision', ['last_user_saved', 'cancel'])
def test_native_version_action_retains_automatic_choice_origin(tmp_path, monkeypatch, decision):
import json
from types import SimpleNamespace
from test_pcb_version_choice import captured
from cbb_refresh_verify.pcb_restore_prompt import RestoreController
monkeypatch.setattr('cbb_refresh_verify.pcb_open_consent.validate_owner', lambda *_: {'target': 'owned'})
controller = RestoreController(dict(root=str(tmp_path), block_name='Block', lmc_file='library.lmc',
project='Block.prj', pcb='Block.pcb', desktop='CbbVerify_test'), user_open=True)
value = captured()
shown, actions = [], []
def perform(snapshot, action, phase):
actions.append(action)
return SimpleNamespace(error_code='', accepted_controls=(6213,), detail='', channel='win32_button_click')
options = dict(target_pid=value.pid, launcher_pid=10, worker_pid=5, companion_pids=(),
show=shown.append, perform=perform)
controller.handle(value, (value,), **options)
shown[0].choose(decision, origin='timeout_default')
result = controller.handle(value, (value,), **options)
record = json.loads((tmp_path/'pcb-version-user-choice.json').read_text('utf-8'))
assert record['choice'] == decision and record['decision_origin'] == 'timeout_default'
if decision == 'cancel':
assert not actions and result.error_code == 'PCB_VERSION_CHOICE_REQUIRED'
else:
assert actions[0]['decision_origin'] == 'timeout_default'
assert actions[0]['target']['control_id'] == 6213