Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Whitestone
45344ca5af fix: update TemplateResponse calls to new Starlette signature
Some checks failed
Tests / test (pull_request) Has been skipped
Tests / lint (pull_request) Failing after 16s
Starlette changed TemplateResponse from TemplateResponse(name, context)
to TemplateResponse(request, name, context). The old calling convention
passed a dict as the 'name' parameter, which Jinja2 tried to use as a
cache key inside a tuple, causing TypeError: unhashable type: 'dict'.

Updated all old-style calls in routes/tools.py and routes/calm.py to
use the new positional-request-first signature and removed redundant
"request" key from context dicts (Starlette adds it automatically).

Fixes #1114

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 14:19:51 -04:00
2 changed files with 10 additions and 8 deletions

View File

@@ -196,7 +196,7 @@ async def get_evening_ritual_form(request: Request, db: Session = Depends(get_db
if not journal_entry: if not journal_entry:
raise HTTPException(status_code=404, detail="No journal entry for today") raise HTTPException(status_code=404, detail="No journal entry for today")
return templates.TemplateResponse( return templates.TemplateResponse(
"calm/evening_ritual_form.html", {"request": request, "journal_entry": journal_entry} request, "calm/evening_ritual_form.html", {"journal_entry": journal_entry}
) )
@@ -257,8 +257,9 @@ async def create_new_task(
# After creating a new task, we might need to re-evaluate NOW/NEXT/LATER, but for simplicity # After creating a new task, we might need to re-evaluate NOW/NEXT/LATER, but for simplicity
# and given the spec, new tasks go to LATER. Promotion happens on completion/deferral. # and given the spec, new tasks go to LATER. Promotion happens on completion/deferral.
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/later_count.html", "calm/partials/later_count.html",
{"request": request, "later_tasks_count": len(get_later_tasks(db))}, {"later_tasks_count": len(get_later_tasks(db))},
) )
@@ -287,9 +288,9 @@ async def start_task(
promote_tasks(db) promote_tasks(db)
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/now_next_later.html", "calm/partials/now_next_later.html",
{ {
"request": request,
"now_task": get_now_task(db), "now_task": get_now_task(db),
"next_task": get_next_task(db), "next_task": get_next_task(db),
"later_tasks_count": len(get_later_tasks(db)), "later_tasks_count": len(get_later_tasks(db)),
@@ -316,9 +317,9 @@ async def complete_task(
promote_tasks(db) promote_tasks(db)
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/now_next_later.html", "calm/partials/now_next_later.html",
{ {
"request": request,
"now_task": get_now_task(db), "now_task": get_now_task(db),
"next_task": get_next_task(db), "next_task": get_next_task(db),
"later_tasks_count": len(get_later_tasks(db)), "later_tasks_count": len(get_later_tasks(db)),
@@ -345,9 +346,9 @@ async def defer_task(
promote_tasks(db) promote_tasks(db)
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/now_next_later.html", "calm/partials/now_next_later.html",
{ {
"request": request,
"now_task": get_now_task(db), "now_task": get_now_task(db),
"next_task": get_next_task(db), "next_task": get_next_task(db),
"later_tasks_count": len(get_later_tasks(db)), "later_tasks_count": len(get_later_tasks(db)),
@@ -360,8 +361,9 @@ async def get_later_tasks_list(request: Request, db: Session = Depends(get_db)):
"""Render the expandable list of LATER tasks.""" """Render the expandable list of LATER tasks."""
later_tasks = get_later_tasks(db) later_tasks = get_later_tasks(db)
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/later_tasks_list.html", "calm/partials/later_tasks_list.html",
{"request": request, "later_tasks": later_tasks}, {"later_tasks": later_tasks},
) )
@@ -404,9 +406,9 @@ async def reorder_tasks(
# Re-render the relevant parts of the UI # Re-render the relevant parts of the UI
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"calm/partials/now_next_later.html", "calm/partials/now_next_later.html",
{ {
"request": request,
"now_task": get_now_task(db), "now_task": get_now_task(db),
"next_task": get_next_task(db), "next_task": get_next_task(db),
"later_tasks_count": len(get_later_tasks(db)), "later_tasks_count": len(get_later_tasks(db)),

View File

@@ -40,9 +40,9 @@ async def tools_page(request: Request):
total_calls = 0 total_calls = 0
return templates.TemplateResponse( return templates.TemplateResponse(
request,
"tools.html", "tools.html",
{ {
"request": request,
"available_tools": available_tools, "available_tools": available_tools,
"agent_tools": agent_tools, "agent_tools": agent_tools,
"total_calls": total_calls, "total_calls": total_calls,