Let a tasks widget have a custom on-panel name
Build and push server image / test (push) Successful in 25s
Build and push server image / build-and-push (push) Successful in 1m59s
Build and push server image / deploy (push) Successful in 53s

Adds TaskWidgetConfig.name (migration 19, plain column add) shown at
the top of the widget on the actual panel instead of the hardcoded
"Tasks" header -- e.g. "Chores" or "Mom's list". The only widget type
with its own on-panel title at all, since it's the only one where
"which list is this" isn't already obvious from a calendar/photo/
whiteboard's own content.

Threaded through calendar_render's _draw_tasks/_build_tasks/
render_tasks/render_tasks_preview_png as a `title` param (default
"Tasks", truncated to fit -- a long custom name shouldn't be able to
overflow the widget's box), the config-save endpoint (tasks_name,
truncated server-side to a sane header length rather than rejected),
and a new "Settings" section in the tasks dialog.

Verified live in the browser: the name actually renders at the top of
the real composited panel (not just the dialog preview, which stays
gated on having a configured source), and persists correctly on both
desktop and mobile. Full suite (196 tests) passes.
This commit is contained in:
Thomas Faour
2026-07-25 04:05:36 +00:00
parent 14c47aa2a0
commit 4a2b1f3795
10 changed files with 120 additions and 20 deletions
+2
View File
@@ -67,12 +67,14 @@ def test_expected_columns_exist_on_current_schema():
inspector = inspect(db_module.engine)
user_columns = {c["name"] for c in inspector.get_columns("users")}
frame_columns = {c["name"] for c in inspector.get_columns("frames")}
task_widget_columns = {c["name"] for c in inspector.get_columns("task_widget_configs")}
assert "webdav_base_url" in user_columns # migration 15
assert "webdav_username" in user_columns # migration 14
assert "calendar_caldav_url" in user_columns
assert "whiteboard_cached_image" in frame_columns # migration 14
assert "calendar_week_start_offset" in frame_columns
assert "name" in task_widget_columns # migration 19
# --- widget system backfill (migration 16 + _ensure_widgets_backfilled) ---
@@ -98,15 +98,31 @@ def test_config_save_updates_a_tasks_widget(client, db_session):
resp = client.post(
f"/api/frames/1/widgets/{widget.id}/config",
data={"tasks_show_completed": "true"},
data={"tasks_name": "Chores", "tasks_show_completed": "true"},
headers=csrf_headers(client),
)
assert resp.status_code == 200, resp.text
cfg = db_session.get(TaskWidgetConfig, widget.id)
assert cfg.name == "Chores"
assert cfg.show_completed is True
def test_config_save_truncates_an_overlong_tasks_name(client, db_session):
client.post("/setup", data={"username": "alice", "password": "hunter22"})
widget = _add_tasks_widget(db_session)
resp = client.post(
f"/api/frames/1/widgets/{widget.id}/config",
data={"tasks_name": "A" * 200},
headers=csrf_headers(client),
)
assert resp.status_code == 200, resp.text
cfg = db_session.get(TaskWidgetConfig, widget.id)
assert len(cfg.name) == 40
def test_config_save_only_partially_updates_provided_fields(client, db_session):
"""Fields not present in the POST are left untouched -- the whole
point of the partial-update convention (each dialog's own form only
+44
View File
@@ -69,6 +69,50 @@ def test_render_with_completed_tasks(db_session, monkeypatch):
assert img.size == (300, 200)
def _capture_build_tasks_title(monkeypatch):
"""Wraps the real _build_tasks to record the `title` it was called
with, while still rendering for real (not a bare stub) so this
keeps exercising the actual render path."""
seen_titles = []
real_build_tasks = widgets.tasks._build_tasks
def spy(tasks, target_w, target_h, palette_rgb=None, title="Tasks"):
seen_titles.append(title)
return real_build_tasks(tasks, target_w, target_h, palette_rgb, title)
monkeypatch.setattr(widgets.tasks, "_build_tasks", spy)
return seen_titles
def test_render_passes_custom_name_as_title(db_session, monkeypatch):
frame, widget = _make_widget(db_session, name="Chores")
monkeypatch.setattr(widgets.tasks, "get_or_refresh_tasks_for_widget", lambda db, frame, widget: [])
seen_titles = _capture_build_tasks_title(monkeypatch)
widgets.tasks.render(db_session, frame, widget, 300, 200)
assert seen_titles == ["Chores"]
def test_render_falls_back_to_default_title_when_name_is_blank(db_session, monkeypatch):
frame, widget = _make_widget(db_session) # name defaults to ""
monkeypatch.setattr(widgets.tasks, "get_or_refresh_tasks_for_widget", lambda db, frame, widget: [])
seen_titles = _capture_build_tasks_title(monkeypatch)
widgets.tasks.render(db_session, frame, widget, 300, 200)
assert seen_titles == ["Tasks"]
def test_render_with_a_very_long_custom_name_still_fits(db_session, monkeypatch):
"""calendar_render._draw_tasks truncates the title to fit -- a name
far longer than any placed widget could display must not error or
overflow the requested size."""
frame, widget = _make_widget(db_session, name="A" * 200)
monkeypatch.setattr(widgets.tasks, "get_or_refresh_tasks_for_widget", lambda db, frame, widget: [])
img = widgets.tasks.render(db_session, frame, widget, 200, 192)
assert img.size == (200, 192)
def test_render_at_minimum_grid_footprint(db_session, monkeypatch):
"""grid.MIN_FOOTPRINT["tasks"] is (2, 2) cells -- on an 8x5 grid
against a full 800x480 panel that's a 200x192 box, the smallest a