From 97b7e85bb2d6710d8208f626d851557741132747 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 21 Nov 2026 09:32:42 +0100 Subject: [PATCH] Show kuhy credit logo on lock, app and web The shared kuhy_credit logo (kuhyx/utils, kuhy-credit-v0.3.1) now sits bottom-right on every lock surface, the aux windows, the status window and the heat-skip prompt; at the end of the workout app's Settings; and in the web dashboard footer. Co-Authored-By: Claude Opus 5.5 --- install_systemd.sh | 3 + pyproject.toml | 1 + requirements.txt | 1 + screen_locker/_credit.py | 35 +++++++ screen_locker/_heat_skip.py | 2 + screen_locker/_window_setup.py | 5 + screen_locker/status_view.py | 2 + screen_locker/tests/conftest.py | 3 + screen_locker/tests/test_lock_credit.py | 98 +++++++++++++++++++ .../lib/screens/settings_screen.dart | 5 + .../workout_app/pubspec.lock | 9 ++ .../workout_app/pubspec.yaml | 6 ++ .../test/screens/settings_screen_test.dart | 13 +++ web/package.json | 1 + web/pnpm-lock.yaml | 10 ++ web/src/env.d.ts | 2 + web/src/layouts/Base.astro | 6 ++ web/src/page.test.ts | 5 + web/src/styles/index.css | 6 ++ 19 files changed, 213 insertions(+) create mode 100644 screen_locker/_credit.py create mode 100644 screen_locker/tests/test_lock_credit.py diff --git a/install_systemd.sh b/install_systemd.sh index dd9d361..055afd7 100755 --- a/install_systemd.sh +++ b/install_systemd.sh @@ -76,6 +76,9 @@ ensure_runtime_deps() { "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.10.0#subdirectory=gatelock" _pip_runtime_dep crdt_sync \ "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync" + # The shared credit logo every lock surface shows (_credit.py). + _pip_runtime_dep kuhy_credit \ + "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit" } ensure_runtime_deps diff --git a/pyproject.toml b/pyproject.toml index 6eb9f59..13ba595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ dependencies = [ "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync", "freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays", "earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time", + "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit", "holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds", "sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays", ] diff --git a/requirements.txt b/requirements.txt index 050c453..2e73b07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=cr earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.16.0#subdirectory=gatelock +kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds mcp==2.3.0 mypy==2.4.1 diff --git a/screen_locker/_credit.py b/screen_locker/_credit.py new file mode 100644 index 0000000..a482b8b --- /dev/null +++ b/screen_locker/_credit.py @@ -0,0 +1,35 @@ +"""kuhy's shared credit logo on screen-locker's Tk windows. + +kuhy, 2026-11-21: the logo goes "everywhere in every single app, desktop +program", lockers too (``kuhy_credit`` README, kuhyx/utils). The widget is +the shared ``kuhy_credit.tk.KuhyCredit``; this module only fixes where it +sits so every window puts it in the same corner. A click on its panel opens +the site in a browser tab, which stays behind the fullscreen lock until the +lock closes. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from kuhy_credit.tk import KuhyCredit + +if TYPE_CHECKING: + import tkinter as tk + + from gatelock import LockConfig + + +def place_credit(parent: tk.Misc, config: LockConfig) -> KuhyCredit: + """Place the logo in ``parent``'s bottom-right corner, above its siblings. + + ``parent`` must be the toplevel (a lock surface or a plain window), never + a content frame a flow clears and repaints. Call it after the window's + full-size viewport exists: siblings stack in creation order, so the logo + lands above it. (``KuhyCredit.lift`` is a Canvas item raise, not a + window raise, so it cannot do this.) + """ + pad = config.space("xl") + credit = KuhyCredit(parent, theme="dark", size=config.type_px("display")) + credit.place(relx=1, rely=1, x=-pad, y=-pad, anchor="se") + return credit diff --git a/screen_locker/_heat_skip.py b/screen_locker/_heat_skip.py index cae672e..21bcaf0 100644 --- a/screen_locker/_heat_skip.py +++ b/screen_locker/_heat_skip.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING from gatelock import LockConfig, bind_activate, bind_cancel from screen_locker._constants import HEAT_SKIP_CITY, HEAT_SKIP_TEMP_THRESHOLD +from screen_locker._credit import place_credit if TYPE_CHECKING: from collections.abc import Callable @@ -143,6 +144,7 @@ class HeatSkipMixin: root.destroy() build_heat_skip_content(root, temp, on_skip=_on_skip, on_decline=_on_no) + place_credit(root, _COLORS) bind_cancel(root, _on_no) root.mainloop() diff --git a/screen_locker/_window_setup.py b/screen_locker/_window_setup.py index 7d921f2..7798889 100644 --- a/screen_locker/_window_setup.py +++ b/screen_locker/_window_setup.py @@ -18,6 +18,7 @@ from gatelock import ( ScrollableSurface, ) +from screen_locker._credit import place_credit from screen_locker._queue_wait import wait_for_screen from screen_locker._surface_group import FrameGroup @@ -116,6 +117,7 @@ class WindowSetupMixin: scroller.container.pack(fill="both", expand=True) self._scrollers["__aux__"] = scroller self.container = FrameGroup([scroller.content]) + place_credit(self.root, self._colors) def build_surface(self, parent: tk.Misc, surface: SurfaceInfo) -> None: """Add one scrollable, keyboard-reachable container for a live output. @@ -141,6 +143,9 @@ class WindowSetupMixin: scroller.container.place(relx=0, rely=0, relwidth=1, relheight=1) self._scrollers[surface.output_name] = scroller self.container.add(scroller.content, surface.output_name) + # On the surface toplevel, not scroller.content: flows clear and + # repaint the content frame, which would wipe the logo. + place_credit(parent, self._colors) def teardown_surface(self, surface: SurfaceInfo) -> None: """Forget the container and viewport for an output that went dark.""" diff --git a/screen_locker/status_view.py b/screen_locker/status_view.py index c7fd435..97d03d4 100644 --- a/screen_locker/status_view.py +++ b/screen_locker/status_view.py @@ -31,6 +31,7 @@ from typing import TYPE_CHECKING from gatelock import LockConfig from screen_locker import _glyphs as g +from screen_locker._credit import place_credit from screen_locker._manual_workout_dialog import ManualWorkoutDialogMixin from screen_locker._status_data import ( StatusSnapshot, @@ -213,6 +214,7 @@ def main(argv: list[str] | None = None) -> None: window.render(gather_status()) window = StatusWindow(root, gather_status(), on_refresh=refresh) + place_credit(root, _STATUS_COLORS) root.mainloop() diff --git a/screen_locker/tests/conftest.py b/screen_locker/tests/conftest.py index 2b2ef62..c6907c4 100644 --- a/screen_locker/tests/conftest.py +++ b/screen_locker/tests/conftest.py @@ -96,6 +96,9 @@ def _block_real_tk_and_exit() -> Iterator[None]: # The startup early-exit checks moved to _startup_checks; sys.exit is # bound there now, so it needs blocking separately. stack.enter_context(patch("screen_locker._startup_checks.sys.exit")) + # The credit logo is a real tk.Canvas from kuhy_credit, outside the + # patched modules above, so it is swapped wholesale too. + stack.enter_context(patch("screen_locker._credit.KuhyCredit")) yield diff --git a/screen_locker/tests/test_lock_credit.py b/screen_locker/tests/test_lock_credit.py new file mode 100644 index 0000000..c9b26af --- /dev/null +++ b/screen_locker/tests/test_lock_credit.py @@ -0,0 +1,98 @@ +"""kuhy's shared credit logo (``kuhy_credit.tk``) on every screen-locker window. + +kuhy, 2026-11-21: the logo goes "everywhere in every single app, desktop +program", lockers included. Each lock surface (one per monitor), the +non-lock aux windows, the status window and the heat-skip prompt get one +logo in their bottom-right corner, on the toplevel itself rather than the +repainted content frame, so a flow repaint never wipes it. + +``KuhyCredit`` is a real ``tk.Canvas``; the autouse fixture swaps it for a +MagicMock (``screen_locker._credit.KuhyCredit``) like it swaps ``tk``. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING +from unittest.mock import MagicMock, patch + +import pytest + +from screen_locker import _credit +from screen_locker._surface_group import FrameGroup +from screen_locker.tests.conftest import create_locker + +if TYPE_CHECKING: + from pathlib import Path + + +def test_place_credit_puts_the_logo_bottom_right() -> None: + parent = MagicMock() + config = MagicMock() + config.space.return_value = 24 + config.type_px.return_value = 40 + + with patch.object(_credit, "KuhyCredit") as credit_cls: + credit = _credit.place_credit(parent, config) + + credit_cls.assert_called_once_with(parent, theme="dark", size=40) + config.type_px.assert_called_once_with("display") + credit.place.assert_called_once_with( + relx=1, rely=1, x=-24, y=-24, anchor="se" + ) + + +@pytest.mark.usefixtures("mock_sys_exit") +class TestLockSurfacesCarryTheCredit: + """The fullscreen lock: one logo per live output, on the toplevel.""" + + def test_each_surface_gets_its_own_logo( + self, mock_tk: MagicMock, tmp_path: Path + ) -> None: + locker = create_locker(mock_tk, tmp_path) + surface = MagicMock() + surface.output_name = "HDMI-1" + parent = MagicMock() + + with patch("screen_locker._window_setup.place_credit") as place: + locker.build_surface(parent, surface) + + place.assert_called_once_with(parent, locker._colors) + + def test_aux_windows_get_a_logo_on_the_root( + self, mock_tk: MagicMock, tmp_path: Path + ) -> None: + locker = create_locker(mock_tk, tmp_path) + locker.container = FrameGroup([]) + + with patch("screen_locker._window_setup.place_credit") as place: + locker._ensure_container() + + place.assert_called_once_with(locker.root, locker._colors) + + +def test_status_window_root_gets_a_logo(mock_tk: MagicMock) -> None: + from screen_locker import status_view + + with ( + patch.object(status_view, "gather_status"), + patch.object(status_view, "StatusWindow"), + patch.object(status_view, "place_credit") as place, + ): + status_view.main([]) + + place.assert_called_once_with( + status_view.tk.Tk.return_value, status_view._STATUS_COLORS + ) + + +def test_heat_skip_prompt_gets_a_logo(mock_tk: MagicMock) -> None: + from screen_locker import _heat_skip + + class _Host(_heat_skip.HeatSkipMixin): + pass + + mock_tk.Tk.return_value.mainloop.side_effect = None + with patch.object(_heat_skip, "place_credit") as place: + _Host()._show_heat_skip_dialog(35.0) + + place.assert_called_once_with(mock_tk.Tk.return_value, _heat_skip._COLORS) diff --git a/stronglift_replacement/workout_app/lib/screens/settings_screen.dart b/stronglift_replacement/workout_app/lib/screens/settings_screen.dart index 292ac88..8bf76a4 100644 --- a/stronglift_replacement/workout_app/lib/screens/settings_screen.dart +++ b/stronglift_replacement/workout_app/lib/screens/settings_screen.dart @@ -11,6 +11,7 @@ import 'dart:developer'; import 'package:crdt_sync/crdt_sync.dart'; import 'package:http/http.dart' as http; +import 'package:kuhy_credit/kuhy_credit.dart'; import 'package:material_ui/material_ui.dart'; import 'package:sync_settings_ui/sync_settings_ui.dart'; import 'package:workout_app/models/exercise.dart'; @@ -239,6 +240,10 @@ class _SettingsScreenState extends State { const SizedBox(height: 20), const _SandboxSection(), ], + // kuhy's shared credit logo (kuhy_credit, kuhyx/utils); the + // app has no about screen, so it closes the Settings list. + const SizedBox(height: 20), + const KuhyCredit(), ], ), ); diff --git a/stronglift_replacement/workout_app/pubspec.lock b/stronglift_replacement/workout_app/pubspec.lock index 0541297..d6fac76 100644 --- a/stronglift_replacement/workout_app/pubspec.lock +++ b/stronglift_replacement/workout_app/pubspec.lock @@ -656,6 +656,15 @@ packages: url: "https://pub.dev" source: hosted version: "4.12.0" + kuhy_credit: + dependency: "direct main" + description: + path: "kuhy_credit/flutter" + ref: "kuhy-credit-v0.3.1" + resolved-ref: "2352c177232a4b4594573a3b1126697ef32851f7" + url: "https://github.com/kuhyx/utils" + source: git + version: "0.3.1" latlong2: dependency: "direct main" description: diff --git a/stronglift_replacement/workout_app/pubspec.yaml b/stronglift_replacement/workout_app/pubspec.yaml index f3e5a55..944e1ff 100644 --- a/stronglift_replacement/workout_app/pubspec.yaml +++ b/stronglift_replacement/workout_app/pubspec.yaml @@ -49,6 +49,12 @@ dependencies: path: google_account_token http: 1.6.0 http_cache_file_store: 2.0.2 + # kuhy's shared "Created by kuhy" logo credit, at the end of Settings. + kuhy_credit: + git: + url: https://github.com/kuhyx/utils + ref: kuhy-credit-v0.3.1 + path: kuhy_credit/flutter latlong2: 0.10.1 material_ui: 1.11.1 path: 1.9.1 diff --git a/stronglift_replacement/workout_app/test/screens/settings_screen_test.dart b/stronglift_replacement/workout_app/test/screens/settings_screen_test.dart index c6a5490..1d5d7f4 100644 --- a/stronglift_replacement/workout_app/test/screens/settings_screen_test.dart +++ b/stronglift_replacement/workout_app/test/screens/settings_screen_test.dart @@ -1,4 +1,5 @@ import 'package:crdt_sync/crdt_sync.dart'; +import 'package:kuhy_credit/kuhy_credit.dart'; import 'package:material_ui/material_ui.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart' as http; @@ -87,6 +88,18 @@ void main() { expect(iconLabeled('Settings'), findsOneWidget); }); + // kuhy, 2026-11-21: the shared credit logo goes in every app; this app has + // no about screen, so it closes the Settings list. + testWidgets('ends with the kuhy credit logo', (tester) async { + await _pump(tester, _wrap()); + await tester.scrollUntilVisible( + find.byType(KuhyCredit), + 400, + scrollable: find.byType(Scrollable).first, + ); + expect(find.byType(KuhyCredit), findsOneWidget); + }); + testWidgets('shows WEIGHTS, TARGET REPS and PER EXERCISE', (tester) async { await _pump(tester, _wrap()); expect(iconLabeled('WEIGHTS'), findsOneWidget); diff --git a/web/package.json b/web/package.json index 424d089..e0adc25 100644 --- a/web/package.json +++ b/web/package.json @@ -15,6 +15,7 @@ "coverage": "vitest run --coverage" }, "dependencies": { + "@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.3.1&path:kuhy_credit/web", "@kuhyx/web-ui": "github:kuhyx/utils#web_ui-v0.5.0&path:/web_ui", "astro": "7.4.13" }, diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 3c2d048..ff858b0 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -175,6 +175,9 @@ importers: .: dependencies: + '@kuhyx/kuhy-credit': + specifier: github:kuhyx/utils#kuhy-credit-v0.3.1&path:kuhy_credit/web + version: https://codeload.github.com/kuhyx/utils/tar.gz/2352c177232a4b4594573a3b1126697ef32851f7#path:kuhy_credit/web '@kuhyx/web-ui': specifier: github:kuhyx/utils#web_ui-v0.5.0&path:/web_ui version: https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.13(@types/node@26.6.6)(yaml@2.9.1)) @@ -831,6 +834,11 @@ packages: '@keyv/serialize@1.1.1': resolution: {integrity: sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==} + '@kuhyx/kuhy-credit@https://codeload.github.com/kuhyx/utils/tar.gz/2352c177232a4b4594573a3b1126697ef32851f7#path:kuhy_credit/web': + resolution: {gitHosted: true, integrity: sha512-QCLKgsTjAquTZMnhG8JQIt884afXrZ1QSwpnQfoO65cJlgWcKLGAM2zqsaK+s6wZFdWGja27wed4b3deIMkTHQ==, path: kuhy_credit/web, tarball: https://codeload.github.com/kuhyx/utils/tar.gz/2352c177232a4b4594573a3b1126697ef32851f7} + version: 0.3.1 + engines: {node: '>=24', pnpm: '>=10'} + '@kuhyx/web-ui@https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui': resolution: {gitHosted: true, integrity: sha512-Uf0AXSh0DaeI/mC7UpgpGrty1g0FlLOIUBtYh1I/qSWiJ/oQeUKoAHfOW/eTJzWurVFLTQMQgP4DFfmBgaz1fw==, path: /web_ui, tarball: https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae} version: 0.5.0 @@ -3298,6 +3306,8 @@ snapshots: '@keyv/serialize@1.1.1': {} + '@kuhyx/kuhy-credit@https://codeload.github.com/kuhyx/utils/tar.gz/2352c177232a4b4594573a3b1126697ef32851f7#path:kuhy_credit/web': {} + '@kuhyx/web-ui@https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.13(@types/node@26.6.6)(yaml@2.9.1))': dependencies: astro: 7.4.13(@types/node@26.6.6)(yaml@2.9.1) diff --git a/web/src/env.d.ts b/web/src/env.d.ts index 97b28c8..f3c9371 100644 --- a/web/src/env.d.ts +++ b/web/src/env.d.ts @@ -6,3 +6,5 @@ declare module '*.astro' { const component: AstroComponentFactory export default component } + +/// diff --git a/web/src/layouts/Base.astro b/web/src/layouts/Base.astro index a6f6d56..a858be4 100644 --- a/web/src/layouts/Base.astro +++ b/web/src/layouts/Base.astro @@ -18,5 +18,11 @@ const { title } = Astro.props +
+ +
+ diff --git a/web/src/page.test.ts b/web/src/page.test.ts index 2429a94..51186e7 100644 --- a/web/src/page.test.ts +++ b/web/src/page.test.ts @@ -32,6 +32,11 @@ describe('index.astro', () => { expect(page).toContain('Reading status…') expect(page).toMatch(/]*role="alert"[^>]*data-errors[^>]*hidden/) }) + + it('renders the kuhy credit in the footer', async () => { + const page = await html() + expect(page).toMatch(/