Skip to content

fix(viewer): display caption for album posts with grouped messages#97

Merged
GeiserX merged 1 commit intoGeiserX:mainfrom
vadimvolk:fix/album-caption-not-displayed
Mar 26, 2026
Merged

fix(viewer): display caption for album posts with grouped messages#97
GeiserX merged 1 commit intoGeiserX:mainfrom
vadimvolk:fix/album-caption-not-displayed

Conversation

@vadimvolk
Copy link
Copy Markdown
Contributor

Summary

  • Album posts (messages sharing the same grouped_id) lose their caption in the viewer when the message carrying the text is not the first one in reverse-chronological sort order
  • Add getAlbumCaption() helper that scans all messages in an album group to find and display the one with non-empty text

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to change)
  • Documentation update
  • Infrastructure/CI change

Database Changes

  • Schema changes (Alembic migration required)
  • Data migration script added in scripts/
  • No database changes

Data Consistency Checklist

N/A — no database code modified.

Root Cause

Messages are sorted newest-first via flex-col-reverse. For an album with grouped_id = 14178103535648053:

id date text role
1261 2026-02-28 07:15:42 (empty) displayed as "first in album"
1260 2026-02-28 07:15:41 (has caption) hidden by isHiddenAlbumMessage()

isFirstInAlbum() picks id=1261 (newer, no caption) as the representative message. The template renders msg.text of that message — which is empty. The actual caption on id=1260 is never shown because that message is hidden.

Additionally, without getAlbumCaption in the Vue return object, the template throws TypeError: getAlbumCaption is not a function, crashing the entire Vue app and showing a blank blue page.

Fix

Three changes in src/web/templates/index.html:

  1. New getAlbumCaption(msg) helper — scans all messages with the same grouped_id and returns the first non-empty text
  2. Template update — changed linkifyText(msg.text) to linkifyText(getAlbumCaption(msg) || msg.text) so albums show the caption regardless of sort order
  3. Vue return object — exposed getAlbumCaption so the template can call it

Steps to Reproduce

  1. Have an album post (2+ photos, same grouped_id) where the caption is on a message that is not the newest in the group
  2. Open the viewer and navigate to that post
  3. Before fix: caption is absent; if the album is the first content loaded, the Vue app crashes with TypeError: getAlbumCaption is not a function (blank blue page)
  4. After fix: caption displays correctly below the album grid

SQL to verify data is present

SELECT id, date, length(text) as text_len, text, raw_data
FROM messages
WHERE id IN (1260, 1261);

SELECT id, message_id, type, file_name
FROM media
WHERE message_id IN (1260, 1261);

Testing

  • Tests pass locally (python -m pytest tests/ -v) — 253 passed, 0 failed (Python 3.14.3)
  • Linting passes (ruff check .)
  • Formatting passes (ruff format --check .)
  • Manually tested in development environment

Security Checklist

  • No secrets or credentials committed
  • User input properly validated/sanitized
  • Authentication/authorization properly checked

Deployment Notes

  • Viewer Docker image rebuild needed
  • No migration or config changes required

Albums group multiple messages by grouped_id, but only one message
carries the caption text. With reverse-chronological sorting, the
displayed "first" message may not be the one with the caption,
causing it to be lost. Add getAlbumCaption() to scan all messages
in the album group and find the one with non-empty text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vadimvolk vadimvolk requested a review from GeiserX as a code owner March 26, 2026 17:34
Copy link
Copy Markdown
Owner

@GeiserX GeiserX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix, correct use of existing album helpers. LGTM.

@GeiserX GeiserX merged commit ef6e994 into GeiserX:main Mar 26, 2026
1 check passed
@GeiserX
Copy link
Copy Markdown
Owner

GeiserX commented Mar 26, 2026

Thanks @vadimvolk! Released as v7.3.2 and deployed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants