Skip to content

feat: badge GitHub-synced comments and propagate to share payload - #604

Merged
tomasz-tomczyk merged 6 commits into
tomasz-tomczyk:mainfrom
Ylsssq926:feat/issue-370-flag-github-synced-comments
May 29, 2026
Merged

tomasz-tomczyk merged 6 commits into
tomasz-tomczyk:mainfrom
Ylsssq926:feat/issue-370-flag-github-synced-comments

Conversation

@Ylsssq926

Copy link
Copy Markdown
Contributor

Why

GitHub-synced comments now carry a visual badge in the review UI, and the share payload includes github_id so crit-web can distinguish them from native crit comments. This closes the two local-side items from the issue: (a) surface the sync origin to reviewers at a glance, and (b) pass that signal through the share endpoint. Closes #370

Key changes

  • share.go: added GitHubID int64 to shareComment / shareReply structs, propagated in commentToShareComment. Two new tests lock the JSON shape for synced and non-synced cases.
  • Frontend: .github-badge pill rendered in both comment headers and reply lists, styled with existing --crit-pill-* tokens. Octocat icon lives as a CSS mask variable (--crit-icon-github) in theme.css to avoid duplicating the data URI.
  • server_test.go: asserts github_id presence in the GET response.
  • e2e: Playwright spec uses the round-complete event path to avoid mtime-based race conditions.

Why no source field

The issue suggested a source: 'github' discriminator alongside github_id. A non-zero github_id already implies GitHub origin unambiguously, so adding a separate enum today would be dead weight. If we later sync from GitLab or Gerrit we can introduce a source field at that point without breaking existing consumers (the comment in share.go documents this decision).

Verification

  • go test -run TestBuildSharePayload ./...
  • go test -run TestHandleFileCommentsGitHubID ./...
  • gofmt -l . && go vet ./...
  • node --test frontend/__tests__/crit-comment-card.test.js
  • cd e2e && npx playwright test tests/github-synced-comment.spec.ts --project=git-mode
  • go test ./... (full regression pass; known TestInstallCodexPluginConfigDefaultsNewFileTo0600 failure on Windows due to 0600 permission semantics is pre-existing and unrelated)

Screenshots

No screenshots attached. If you'd like specific scenarios captured (light/dark, mobile viewport, stacked badges on a reply) I can put together a fixture and grab them.

Out of scope

  • crit-web rendering of the badge (tracked separately per issue item (c))
  • Other sync sources; switching to a source enum makes sense only when we add a second provider

Notes

The frontend unit tests (frontend/__tests__/*.test.js) aren't wired into CI today. They run locally via node --test and inside make e2e-live-utils, but that target isn't in the GitHub Actions workflow. Not something to fix in this PR, just flagging it.

@tomasz-tomczyk

Copy link
Copy Markdown
Owner

Thank you! Sorry it's taking me a while to get around to this. I'll review today ❤️

Ylsssq926 and others added 3 commits May 29, 2026 22:49
Comments synced from a GitHub PR carry their review-comment ID into
the shared review JSON, so crit-web (and any other consumer of the
share payload) can tell GitHub-synced comments apart from native
crit comments.

The new field is omitempty: locally-authored comments produce the
same wire output as before. Replies carry the same field for the
same reason.

Verification:
[x] go test -run TestBuildSharePayload ./...
[x] go test -run TestHandleFileCommentsGitHubID ./...
[x] gofmt -l . && go vet ./...
When a comment or reply has a non-zero github_id we paint a small
"GitHub" pill in the card header. The badge uses the neutral pill
tokens (informational, not a warning) and a shared --crit-icon-github
CSS variable so the SVG mask is defined once in theme.css.

Class renamed from .comment-card-gh-badge to .github-badge to match
the project convention (.outdated-badge, .live-thread-badge).

Verification:
[x] node --test frontend/__tests__/crit-comment-card.test.js
[x] cd e2e && npx playwright test tests/github-synced-comment.spec.ts --project=git-mode
The .github-badge text color and its masked octocat icon paint are both
driven by var(--crit-pill-fg). That token existed when this branch was
authored but was later removed from theme.css on main (tomasz-tomczyk#612/tomasz-tomczyk#300), so on
current main the badge icon paints with an undefined color (transparent)
and the GitHub mark disappears. Re-add --crit-pill-fg to all four theme
blocks so the badge renders as intended; check-css-vars.sh passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@tomasz-tomczyk
tomasz-tomczyk force-pushed the feat/issue-370-flag-github-synced-comments branch from 656c0d3 to 88bc1c6 Compare May 29, 2026 22:01
tomasz-tomczyk and others added 2 commits May 29, 2026 23:04
Instance 1 (markdown) injects a GitHub-synced comment with a synced reply,
plus a synced reply mixed into a native thread, into the review file after
finish. The daemon's file watcher merges them (preserving github_id), so the
.github-badge from this PR renders in a real review. Gives `make test-diff`
a local visual fixture for the tomasz-tomczyk#370 badge alongside native comments.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`func truncate` is defined in both roundtrip_integration_test.go and
share_test.go (the latter added by tomasz-tomczyk#505). They only collide when compiled
together under the e2e_github build tag, which CI never builds — so
`make e2e-roundtrip` failed with 'truncate redeclared in this block'.
Remove the copy from the tagged file; it now resolves to the always-compiled
share_test.go helper. Unblocks the crit<->GitHub roundtrip suite, which is
the real github_id pull/push persistence coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@tomasz-tomczyk

Copy link
Copy Markdown
Owner

Thank you! Looks great! I just added it to our local 'seeds' in make test-diff to easily eyeball and rebased. 🧡 💛

ESLint (the lint-frontend CI job) flags `var ghBadge` under no-var. Switch
the badge element to const in both the reply renderer (app.js) and the
comment-card header (crit-comment-card.js).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.68%. Comparing base (36fc25e) to head (0574eea).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #604      +/-   ##
==========================================
+ Coverage   70.63%   70.68%   +0.04%     
==========================================
  Files          54       54              
  Lines       14243    14248       +5     
==========================================
+ Hits        10061    10071      +10     
+ Misses       3412     3409       -3     
+ Partials      770      768       -2     
Flag Coverage Δ
e2e 29.75% <16.66%> (+0.01%) ⬆️
unit 68.75% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasz-tomczyk
tomasz-tomczyk merged commit 1039fba into tomasz-tomczyk:main May 29, 2026
17 of 18 checks passed
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.

Flag GitHub-synced comments and share that signal with crit-web

2 participants