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 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-21 09:32:42 +01:00
parent 3595b61902
commit 97b7e85bb2
19 changed files with 213 additions and 0 deletions

View File

@ -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

View File

@ -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",
]

View File

@ -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

35
screen_locker/_credit.py Normal file
View File

@ -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

View File

@ -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()

View File

@ -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."""

View File

@ -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()

View File

@ -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

View File

@ -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)

View File

@ -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<SettingsScreen> {
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(),
],
),
);

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -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"
},

View File

@ -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)

2
web/src/env.d.ts vendored
View File

@ -6,3 +6,5 @@ declare module '*.astro' {
const component: AstroComponentFactory
export default component
}
/// <reference path="../node_modules/@kuhyx/kuhy-credit/src/kuhy-credit.d.ts" />

View File

@ -18,5 +18,11 @@ const { title } = Astro.props
</head>
<body>
<slot />
<footer class="site-footer">
<kuhy-credit></kuhy-credit>
</footer>
<script>
import '@kuhyx/kuhy-credit'
</script>
</body>
</html>

View File

@ -32,6 +32,11 @@ describe('index.astro', () => {
expect(page).toContain('Reading status…')
expect(page).toMatch(/<div[^>]*role="alert"[^>]*data-errors[^>]*hidden/)
})
it('renders the kuhy credit in the footer', async () => {
const page = await html()
expect(page).toMatch(/<footer class="site-footer">\s*<kuhy-credit><\/kuhy-credit>/)
})
})
/** Tag name plus sorted attribute names, for every tag carrying a data-* hook. */

View File

@ -101,3 +101,9 @@ td {
[data-slot] {
overflow-x: auto;
}
.site-footer {
display: flex;
justify-content: flex-end;
padding: var(--space-4);
}