Repository navigation
Show the creation day in a card's full history - #21
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Someone who expands "Full history" on a card sees moves, assignments and title changes. They cannot see the day the card was created.
Expanded history starts with a row that states who created the card and on which day. The collapsed view stays as it is today.
Implementation
Domain terms
No glossary exists in this repository. Terms used in this plan:
Commentwhose creator is the account's system user, rendered inside.comment-by-system..comments--system-expanded), toggled by the "Full history" button.card.created_at. It is not aCommentand is never stored.Diagrams
Signatures
Not affected: no Ruby class or method is added or changed. The new partial
app/views/cards/_creation.html.erbtakes one local,card:.Not checked: Fizzy has no Steep or rbs_rails setup, and this change adds no Ruby method.
Complexity
At most one extra query per card page: a primary-key lookup of the card's creator in
users.CardsController#set_carddoes not preloadcreator. On a coldcards/_containerfragment cache,cards/display/common/_meta.html.erbloads it first and the creation row adds zero queries. On a warm cache,_metais skipped and the creation row loads it. The row reads no other association. The partial is O(1) and is not fragment-cached, because it holds only the creator name and a client-formatted time tag.Invariants
.comment-by-systemchild of the messages frame. Enforced by render order in_messages.html.erb.:not(.comment-by-system--creation)in the twonth-*-child(… of …)selectors incomments.css..comment-by-system/.comments--system-expandedrules.card.published?guard in_messages.html.erb(andCardsController#showredirects drafts).Alternatives
comment-by-system comment-by-system--creation, so it gets the striped, centred, avatar-less look and the hide/expand rules for free. Two CSS selectors gain:not(.comment-by-system--creation)so the collapsed view and the button logic count exactly the same rows as today. Cost: two selector edits; zero queries; no duplicated CSS.card.comments.by_system.many?, no CSS edits. It adds a COUNT query per card page, duplicates the CSS "two or more" rule in Ruby, and goes stale: when a broadcast adds the second system comment, the button appears but the creation row is missing until the next full render..comment-creationclass with its own CSS. It leaves every existing selector untouched, and the row can stay hidden until.comments--system-expandedis present, because the existing system-comment selectors already gate the button. But it must repeat about 12 lines of the.comment-by-system .commentstyling (centring, spacer, stripe gradient, expanded stripe colour), or widen each of those shared selectors to a second class. The system-row look can then drift between two copies.app/views/cards/_creation.html.erb— new partial:<div id="<%= dom_id(card, :creation) %>" class="comment-by-system comment-by-system--creation">>div.comment.align-start.full-width>div.comment__content.flex.flex-column.flex-item-grow.full-width>div.comment__author.flex.align-center.gap-half>h3.font-weight-normal.txt-normal.flex-item-justify-start.min-width.overflow-ellipsis>span.comment__permalink-titlewithlocal_datetime_tag card.created_at, style: :date; thendiv.comment__bodywith<strong>Created</strong> by <%= card.creator.name %>. No avatar, history button, edit link or reactions.app/views/cards/_messages.html.erb— insideif card.published?, rendercards/creationbefore the comment collection.app/assets/stylesheets/comments.css— change:nth-last-child(1 of .comment-by-system)to:nth-last-child(1 of .comment-by-system:not(.comment-by-system--creation)), and:nth-child(1 of .comment-by-system)to:nth-child(1 of .comment-by-system:not(.comment-by-system--creation)).test/system/card_history_test.rb— new system test.test/controllers/cards_controller_test.rb— new show tests.test/views/cards/creation_test.rb— new partial tests.Proof
test/system/card_history_test.rbtest "full history shows the creation row first"(cards(:logo), creator David: before the click "Created by David" is not visible; after it, the text is visible and the creation row is the first visible.comment-by-system)test/system/card_history_test.rbtest "a card with one system comment shows no full history button and no creation row"(cards(:layout)) andtest "a card with no system comments shows no creation row"(cards(:buy_domain), which has no comments)test/system/card_history_test.rbtest "collapsing the full history hides the creation row"test/controllers/cards_controller_test.rbtest "show renders the creation row from the card's created_at"(cards(:logo), a fixture card with no creation event or creation comment; assertstime[data-local-time-target=date][datetime=?]withcard.created_at.to_iinside#creation_card_…, and the text "Created by David")test/views/cards/creation_test.rbtest "renders with one query when the creator is not loaded"(assert_queries_count(1) { render "cards/creation", card: Card.find(cards(:logo).id) }) andtest "renders without queries once the creator is loaded"(assert_no_queries { … }aftercard.creatoris read).comment-by-systemand does not change the number of real system rows, enforced by render order in_messages.html.erb→test/controllers/cards_controller_test.rbtest "show renders the creation row before the system comments"(first.comment-by-systemhas the creation id;.comment-by-system:not(.comment-by-system--creation)count equals the card's system comment count):not(.comment-by-system--creation)selectors incomments.css→test/system/card_history_test.rbtest "a card with one system comment shows no full history button and no creation row"