Fix #89: Render attachments and embeds on post front page listing #121
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "typosaurus/ticket-89"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #89.
Plan
Implementation Plan
1. Fix Profile Posts Tab – Add Attachment Fetch
File:
routers/profile/index.pyLocation: After the posts query (lines ~170–195), where
postsis the list of post row objects returned from the database.Action: Insert a batch attachment fetch identical to
routers/feed.py:97–106.post_uidvalues from the fetched posts.get_attachments_by_type("post", post_uids)(orget_attachments_batch(post_uids)) from the attachments service."attachments"(matching the structure expected by_post_card.html:20).Rationale: The profile template already uses
_post_card.html, which renders attachments when theattachmentskey is present. The only missing piece is populating that key in the profile route.2. Keep Truncation Separately Scoped (No Change)
The 300-character truncation of post body (
_post_card.html:18) is a known limitation that affects inline embeds (YouTube URLs, etc.) beyond the 300th character. While it can cause user confusion, it is not the reported bug (which is about file attachments). To minimise risk of layout regressions and unrelated test failures, do not alter the truncation length in this change.3. Add Tests for Attachment Rendering on Profile Posts Tab
File:
tests/api/profile.py(or a new moduletests/e2e/profile.pyif e2e structure exists)Minimum test coverage:
/profile/{username}?tab=posts) via the API client.attachmentsfield (oritem.attachments) the attachment metadata is present.Optionally write an e2e test that uses
page.gototo verify the HTML actually renders the attachment’s<img>or<video>tag on the profile page.Also update
tests/unit/services/content.pyif there is a test forenrich_itemsto verify that attachment enrichment works in the profile context (but this may require mocking).4. Ensure No New Lint Violations
ruff check --diff(or the project’s linter equivalent) on the changed files.5. Verify No Regression in Existing Tests
Run the project’s verification command:
The command will be executed by the CI. Ensure that no new failures are introduced (earlier failures in
test_advance_quests_increments_and_capsortest_answer_is_grounded_and_citedare pre-existing and unrelated; they should still pass if flakiness is resolved, but our change must not cause them to fail).Definition of Done
routers/profile/index.pyis updated to fetch and attach attachment data for posts returned on the profile tab.pip install -e '.[dev]' -q && python -m pytest {test_files}.Opened automatically by Typosaurus.
Checkout
From your project repository, check out a new branch and test the changes.