Repository navigation
Conversation
LockScreenPublicationTests runs whole updates of the unchanged service and pins what each one publishes and asks. Once the modes are on, a monitor tick that finds nothing new asks for the desktop's scenes once, publishes nothing and never asks whether the displays are away. A change of the scenes, of a staged file with the content revision, or of the modes asked for publishes again; a change that stages the same files does not, nor does a file that changes after it while the content revision stays; a choice that changes no scene publishes once more; and the extension is prepared again only for a mode not yet shown. An update that finds everything as the lock screen was last shown with still waits for a first frame the lock screen is owed. A display that leaves is kept while the displays are away and dropped while they are awake. Switching a mode off, or its own wallpaper failing to load, gives back that mode alone before any display needs its UUID, and a store race while a failed wallpaper's mode is given back is not retried. A mode with nothing of its own to show is published off. Each row runs on a fixture of its own, with a stand-in renderer that answers each publication unless the row holds it back. Signed-off-by: Morax <James20081204@gmail.com>
…onLedger The service kept eight fields on what it last published, how far the extension had confirmed it and what the last completed update was for, and decided over them inline: whether an update finds nothing new, as a steady tick does; whether a staged configuration is the published one again; whether publishing turns on a mode the extension does not show yet; which published modes a request or a failed wallpaper turns off; and which departed displays keep the committed scenes while the displays are away. LockScreenPublicationLedger now holds those fields and makes those decisions. The service still writes every file, waits for every first frame and takes its durable steps in the same order. The two rules that need more than the ledger are pure statics with table tests. heldDisplays takes the displays shown, the published inputs, the resolution and the question whether the displays are away, which it asks only when a display that showed a scene is no longer named. configuration takes the staged configuration, whether each mode is asked for (the lock screen only while it has not failed to activate) and the resolution, and turns on each mode that found no error and shows a scene. An update still remembers its target with the requests as they stand when it completes, and still reads the requests and sources again after every wait. Signed-off-by: Morax <James20081204@gmail.com>
…to 6.3 The publication ledger takes LockScreenWallpaperService.swift from 5.45 to 6.30. Signed-off-by: Morax <James20081204@gmail.com>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| LockScreenWallpaperService.swift | 5.46 → 6.30 | Complex Method, Complex Conditional, Large Method, Bumpy Road Ahead, Overall Code Complexity |
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
Action performed
|
What and why
Part E of package 1.3 in the code-health refactoring. It's stacked on part D, #323 (branch
capy/lock-screen-scene-resolver), and merges after it; part F is stacked on this one.LockScreenWallpaperServicekept eight fields on what it last published, how far the extension had confirmed it and what the last completed update was for, and decided over them inline: whether an update finds nothing new, as a steady tick does; whether a staged configuration is the published one again; whether publishing turns on a mode the extension doesn't show yet; which published modes a request or a failed wallpaper turns off; and which departed displays keep the committed scenes while the displays are away. This PR moves the fields and those decisions into a ledger. That fixes CodeScene's Complex Method onrelinquishModes(cyclomatic complexity 10) and the Complex Conditional left inupdate, and takesupdatefrom cyclomatic complexity 75 to 50. The service still writes every file, waits for every first frame and takes its durable steps in the same order. Nothing changes for someone using the app.LockScreenPublicationLedger(struct, new file) holds the eight fields:published,publishedInputs,unconfirmed,forceRepublish,lastInputs,lastContentRevision,lastLockScreenRequestedandlastScreenSaverRequested. The service keeps one inledgerand sets every field at the same points as before. Its rules replace the inline expressions:disables(lockScreen:screenSaver:)says whether a request turns off a published mode. It serves the disable taken at entry, the one taken after the resolution, and the guard inrelinquishModes.steadyPublication(for:),samePublication(as:),activatesMode(_:),isAwaitingFirstFrame(of:),shownDisplaysandremember(_:).steadyPublication(for:)andremember(_:)take theLockScreenPublishTargetthat the transient retry already builds, so there's no new type for the last update.heldDisplays(_:)(TopologyFacts) decides the topology hold, andconfiguration(_:)(ModeFacts) turns on each mode that is asked for, found no error and shows a scene, makes an independent mode's empty list explicit and drops the scenes of each mode it has off.heldNoticesand the statuses.LockScreen/row says what the ledger holds and decides, and docs/testing/coverage.md describes both new suites and lists the publication suite among those that share the service fixture. scripts/code_health_baseline.json records the service at 6.3.The hazards, one by one.
publishreads and setsledger.publishedwhere it read and setpublished. The order of the file, the request and the notification is unchanged, and the ordered recorder rows inLockScreenRecoveryTestspass unchanged.relinquishModes. The guard inrelinquishModesnow asksledger.disablesbefore it bindspublishedandpublishedInputs. All three are pure reads, so it returns in exactly the cases it did, and apart from theledger.prefix the body is the same. The saver-only demotion reads the flags ofledger.published.testAModeSwitchedOffIsGivenBackAlonecovers this in 9 rows.ledger.forceRepublishandledger.lastInputsat the same points.LockScreenWallpaperServiceTestspasses and wasn't edited.applySelectionand the restores run at the same moments, andapplySelectionstill records the inputs first.LockScreenStagingTestspasses. The mode flags are still set on the staged configuration. One intermediate step differs for an independent lock screen whose activation failed: the old code first set its list to[]and then, because the mode was off,removeDisabledSources()set it back tonil.ModeFacts.lockScreenmeans "asked for and hasn't failed to activate", so the new code skips the[]. The published file is the same.LockScreenModeSettingsTestspasses.forceRepublishis now a write toledger.forceRepublishat the same point, and the facts the transient retry takes read the same values from the ledger.LockScreenTransientRetryTestsandLockScreenRecoveryTestspass.rendererExitedreadsledger.publishedand setsledger.forceRepublishin the same cases, andrendererWatch.retire(ledger.published)still runs beforepublish.LockScreenRendererWatchTestspasses.disablesreads the requests at entry, as before, and the mode facts read them right after thegeneration == revision, anyRequestedguard, where the old block read them.steadyPublication(for:)uses the target built one statement earlier, with no suspension between, so it sees what the old inline reads saw. An update still remembers its target with the requests as they stand when it completes.@MainActorservice, and only the service touches it.TopologyFactsis built and used in the same synchronous step.activatesModeis the old condition.scenes()call, publishes nothing and never asks whether the displays are away. The "nothing changed" row oftestAnUpdateAfterTheActivationPublishesOnlyWhatChangedcounts all three. The only extra work isshownDisplays: the old code built the same set whenever something was published, and now it's also built, empty, before the first publication. There are no new reads, encodes or file writes.Tests. The first commit pins today's behaviour on the unchanged service.
LockScreenPublicationTestsruns whole updates, each row on a fixture of its own with a stand-in renderer that answers each publication unless the row holds it back, in 5 tests and 29 rows:Before the refactor, 39 mutations of the unchanged service ran, each applied alone. 30 failed this suite and 5 more failed other lock-screen suites. Three of the four that survived every suite were real gaps and got a test or a row in this commit: a steady skip that ignores a first frame still owed (
testAnUpdateThatFindsNothingNewWaitsForAFirstFrameStillOwed), no disable taken from the source errors (the row "a store race while the screen saver's failed wallpaper is given back"), and an identical configuration not remembered (the row "the content revision moved, then the desktop's video changed without it"). The fourth makes the lock screen's flag ignore an empty list of scenes. It is equivalent through the service, by argument rather than by a test; applied to the ledger after the refactor, it failsLockScreenPublicationLedgerTests/testAModeIsPublishedWhenAskedForWithoutErrorAndShowingAScene.The refactor commit adds
LockScreenPublicationLedgerTests, 7 tests and 57 rows that pin each rule on its own.Commits.
51cd91b2etest(lock-screen): pin which updates publish, keep or give a mode back28a1a3114refactor(lock-screen): keep what was published in LockScreenPublicationLedger76742ac8echore(scripts): raise the lock-screen service's code health baseline to 6.3Verification
E was first made on fc1daf4b4, part D's head before the rebase. It was rebased onto D's new head a246333 with
git rebase --onto, without conflicts.git range-diffshows all three commits unchanged, andgit patch-id --stableover E's own diff gives b5da13e0daaf before and after.git merge-tree --write-tree origin/main 76742ac8eexits 0 against main at 2004873.On 76742ac, after the rebase:
xcodegen generate(2.45.4) exits 0 and leaves the tree clean.python3 scripts/check_code_health.py --base origin/main: "OK code health: 9 of 9 file(s) reviewed, 0 below the ratchet, 0 improved, 1 without a score". It reviews D's files as well as E's, because its merge base with main is D's base, and the file without a score is D's LockScreenSceneResolution.swift. With nothing improved and nothing to record, the baseline commit holds exactly what--update-baselinewrites.Code health against part D (a246333), from
cs reviewof each file at both revisions:cs delta a24633382 76742ac8elists only the service, with only improved and fixed issues.updategoes from cyclomatic complexity 75 to 50, from 279 lines to 249 and from 6 bumps to 5, and its Complex Conditional is fixed.relinquishModesis no longer a Complex Method.setSource's 2 bumps andrefresh's conditional are unchanged. Nothing is new or degraded in any file.Gate after the rebase.
python3 scripts/test.pydidn't run on 76742ac itself. It ran once, on F's head 0ff4a51, which carries E's three commits unchanged: "Passed: 5772 passed, 0 failed, 70 skipped of 5842 in 192s", exit 0 (Tests-20261201-121846-890678). Its two runtime warnings, both "This method should not be called on the main thread as it may lead to UI unresponsiveness.", are in two video tests outside the lock screen. That build linked a renderer library built before #311, so #311's renderer change wasn't in the run; E doesn't touch the renderer.Before the rebase, on D's old head fc1daf4b4:
LockScreenPublicationTestspassed 5 of 5 on the unchanged service, and the 16 lock-screen suites passed 251 of 251 at the test commit.LockScreenPublicationLedgerTestsas the 17th suite: 258 of 258.python3 scripts/test.pyon 22f137806, E's head then: "Passed: 5755 passed, 0 failed, 70 skipped of 5825 in 170s", exit 0, with no runtime warnings and no temporary service roots left behind.Not verified: no Release build, and the app wasn't run. That the one surviving mutation is equivalent through the service is an argument, not a test.
Left alone. These findings in the service are older than this part:
updateat cyclomatic complexity 50, 249 lines and 5 bumps, which part F takes on; andsetSource's 2 bumps, the conditional inrefreshand the file's Low Cohesion, which stay.python3 scripts/test.pypasses: on F's head after the rebase, which carries this PR unchanged, and on 22f137806 before itChecklist
release:line in the title or any commit messagepython3 scripts/check_code_health.py --update-baseline, as checked abovegit commit -s): every commit carries aSigned-off-bytrailer with this Mac's git identity, added by the agent that prepared them. The box is left for the owner to tick.