Skip to content

Show the creation day in a card's full history - #21

Merged
eirvandelden merged 6 commits into
mainfrom
card-history-creation-day
Nov 6, 2026
Merged

eirvandelden merged 6 commits into
mainfrom
card-history-creation-day

Conversation

@eirvandelden

Copy link
Copy Markdown
Owner

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:

  • System comment: a Comment whose creator is the account's system user, rendered inside .comment-by-system.
  • Full history: the expanded state of a card's messages frame (.comments--system-expanded), toggled by the "Full history" button.
  • Collapsed view: the default state, where only the last system comment shows.
  • Creation row (new): a view-only row, "Created by " plus the creation day, built from card.created_at. It is not a Comment and is never stored.

Diagrams

classDiagram
  class Messages["cards/_messages.html.erb"]
  class CreationRow["cards/_creation.html.erb (new)"]
  class CommentRow["cards/comments/_comment.html.erb"]
  class Card
  Messages --> CreationRow : renders first, published cards only
  Messages --> CommentRow : renders 0..n, chronologically
  CreationRow --> Card : reads created_at, creator.name
Loading
stateDiagram-v2
  [*] --> Collapsed
  Collapsed --> Expanded : click "Full history" (needs 2+ system comments)
  Expanded --> Collapsed : click "Full history"
  Collapsed : creation row hidden
  Expanded : creation row shown first
Loading

Signatures

Not affected: no Ruby class or method is added or changed. The new partial app/views/cards/_creation.html.erb takes 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_card does not preload creator. On a cold cards/_container fragment cache, cards/display/common/_meta.html.erb loads it first and the creation row adds zero queries. On a warm cache, _meta is 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

  • The creation row is the first .comment-by-system child of the messages frame. Enforced by render order in _messages.html.erb.
  • The creation row never counts as a system comment for the collapsed view or the button. Enforced by :not(.comment-by-system--creation) in the two nth-*-child(… of …) selectors in comments.css.
  • The creation row shows only when the history is expanded. Enforced by the existing .comment-by-system / .comments--system-expanded rules.
  • Drafts never render the creation row. Enforced by the existing card.published? guard in _messages.html.erb (and CardsController#show redirects drafts).

Alternatives

  1. Chosen — reuse the system row with a modifier class. The row carries 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.
  2. Rejected — render only when 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.
  3. Rejected — isolated .comment-creation class with its own CSS. It leaves every existing selector untouched, and the row can stay hidden until .comments--system-expanded is present, because the existing system-comment selectors already gate the button. But it must repeat about 12 lines of the .comment-by-system .comment styling (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-title with local_datetime_tag card.created_at, style: :date; then div.comment__body with <strong>Created</strong> by <%= card.creator.name %>. No avatar, history button, edit link or reactions.
  • app/views/cards/_messages.html.erb — inside if card.published?, render cards/creation before 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

  • Clicking "Full history" on a card shows "Created by Ana" with the creation day above the first move → test/system/card_history_test.rb test "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)
  • A card with no other history has no "Full history" button and shows no creation row → test/system/card_history_test.rb test "a card with one system comment shows no full history button and no creation row" (cards(:layout)) and test "a card with no system comments shows no creation row" (cards(:buy_domain), which has no comments)
  • Collapsing the history hides the creation row again → test/system/card_history_test.rb test "collapsing the full history hides the creation row"
  • A card created before this change shows its creation row too → test/controllers/cards_controller_test.rb test "show renders the creation row from the card's created_at" (cards(:logo), a fixture card with no creation event or creation comment; asserts time[data-local-time-target=date][datetime=?] with card.created_at.to_i inside #creation_card_…, and the text "Created by David")
  • Query count: the creation row adds at most one query, a lookup of the creator → test/views/cards/creation_test.rb test "renders with one query when the creator is not loaded" (assert_queries_count(1) { render "cards/creation", card: Card.find(cards(:logo).id) }) and test "renders without queries once the creator is loaded" (assert_no_queries { … } after card.creator is read)
  • Invariant: the creation row is the first .comment-by-system and does not change the number of real system rows, enforced by render order in _messages.html.erb → test/controllers/cards_controller_test.rb test "show renders the creation row before the system comments" (first .comment-by-system has the creation id; .comment-by-system:not(.comment-by-system--creation) count equals the card's system comment count)
  • Invariant: the button logic ignores the creation row, enforced by the :not(.comment-by-system--creation) selectors in comments.css → test/system/card_history_test.rb test "a card with one system comment shows no full history button and no creation row"

@eirvandelden
eirvandelden marked this pull request as ready for review November 6, 2026 20:35
@eirvandelden
eirvandelden merged commit ebf3165 into main Nov 6, 2026
3 of 7 checks passed
@eirvandelden
eirvandelden deleted the card-history-creation-day branch November 6, 2026 20:49
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.

1 participant