aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/server.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 16:55:40 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 16:55:40 +0100
commit87e5b715075fb56343d2d10a6a532d04d8fc615b (patch)
tree571764784ff69cf604d2b47cb6ff2d0e189a6592 /deckit/server.py
parent5a6359af175a0dac3c7c03d7b76bdaa59dadcb61 (diff)
downloaddeck-it-87e5b715075fb56343d2d10a6a532d04d8fc615b.tar.gz
deck-it-87e5b715075fb56343d2d10a6a532d04d8fc615b.zip
feat(assistant): the transcript as chat bubbles with avatars
Questions sit on the right in an accent bubble with the user's avatar (`[assistant] user_avatar`, served at /api/avatar); replies on the left in a surface bubble with the assistant's, a "…" bubble while a reply has no text yet. The assistant's avatar is the background picture itself, zoomed by CSS onto `[assistant] face` ([centre x, centre y, size] in its pixels), so nothing is cropped on the PC; the page loads the picture once for its real size. Unset, both are plain circles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deckit/server.py')
-rw-r--r--deckit/server.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/deckit/server.py b/deckit/server.py
index 9dd5229..f3e1976 100644
--- a/deckit/server.py
+++ b/deckit/server.py
@@ -112,9 +112,13 @@ def art():
return None
-def background():
- """The Assistant tab's backdrop, `[assistant] background`; None when unset."""
- name = CFG.get("assistant", {}).get("background", "")
+# /api/<route> -> the [assistant] key naming a local image to serve there.
+CONFIG_IMAGES = {"bg": "background", "avatar": "user_avatar"}
+
+
+def config_image(key):
+ """The Assistant tab's backdrop or the user's avatar; None when unset."""
+ name = CFG.get("assistant", {}).get(key, "")
path = Path(name).expanduser()
try:
return (path.read_bytes(), mimetypes.guess_type(path)[0] or "image/jpeg") if name else None
@@ -208,8 +212,8 @@ class Handler(BaseHTTPRequestHandler):
if len(parts) == 2 and parts[1] == "art":
image = art()
return self._send(200, image[0], image[1], cache=True) if image else self._send(404)
- if len(parts) == 2 and parts[1] == "bg":
- image = background()
+ if len(parts) == 2 and parts[1] in CONFIG_IMAGES:
+ image = config_image(CONFIG_IMAGES[parts[1]])
return self._send(200, image[0], image[1], cache=True) if image else self._send(404)
if len(parts) == 4 and parts[2] == "image":
try: