Julien Simon Claude Opus 4.5 commited on
Commit
fb139a8
·
1 Parent(s): 32fec16

Add Share on X button after review completes

Browse files

Opens Twitter's share intent with a pre-filled post containing the
review mode, trimmed verdicts, and app URL. Button appears alongside
the Copy button only after streaming finishes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (3) hide show
  1. public/app.js +28 -0
  2. public/index.html +5 -0
  3. public/style.css +25 -1
public/app.js CHANGED
@@ -14,6 +14,7 @@ const tabButtons = document.querySelectorAll(".tab");
14
  const brutalityBtns = document.querySelectorAll(".brutality-btn");
15
  const issueBadge = document.getElementById("issue-badge");
16
  const copyBtn = document.getElementById("copy-btn");
 
17
  const toast = document.getElementById("toast");
18
 
19
  const GITHUB_BLOB_RE = /^https?:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[^/]+\/.+$/;
@@ -239,6 +240,31 @@ function renderIssueBadge(counts) {
239
  issueBadge.hidden = false;
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  /* --- Copy to clipboard --- */
243
 
244
  function buildMarkdownExport() {
@@ -319,6 +345,7 @@ function startReview() {
319
  });
320
  issueBadge.hidden = true;
321
  copyBtn.hidden = true;
 
322
  fullMarkdown = "";
323
 
324
  if (!url) { showInputError("Please enter a GitHub file URL."); return; }
@@ -363,6 +390,7 @@ function startReview() {
363
  const counts = countIssuePriorities(markdown);
364
  renderIssueBadge(counts);
365
  copyBtn.hidden = false;
 
366
  });
367
 
368
  source.addEventListener("error", (e) => {
 
14
  const brutalityBtns = document.querySelectorAll(".brutality-btn");
15
  const issueBadge = document.getElementById("issue-badge");
16
  const copyBtn = document.getElementById("copy-btn");
17
+ const shareXBtn = document.getElementById("share-x-btn");
18
  const toast = document.getElementById("toast");
19
 
20
  const GITHUB_BLOB_RE = /^https?:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[^/]+\/.+$/;
 
240
  issueBadge.hidden = false;
241
  }
242
 
243
+ /* --- Share on X --- */
244
+
245
+ function stripMarkdown(md) {
246
+ return md.replace(/\*\*/g, "").replace(/^#+\s*/gm, "").replace(/\n{2,}/g, "\n").trim();
247
+ }
248
+
249
+ function shareOnX() {
250
+ const url = urlInput.value.trim();
251
+ const mode = brutalityLevel;
252
+ const verdicts = stripMarkdown(currentSections.verdicts || "");
253
+
254
+ const header = `I reviewed code with Arcee AI Trinity Large in ${mode} mode and here's what Linus, Knuth, and Bjarne had to say:\n\n`;
255
+ const footer = `\n\nTry it yourself: https://huggingface.co/spaces/julien-c/trinity-large\n${url}`;
256
+ const maxVerdicts = 280 - header.length - footer.length;
257
+ const trimmedVerdicts = verdicts.length > maxVerdicts
258
+ ? verdicts.slice(0, maxVerdicts - 1) + "\u2026"
259
+ : verdicts;
260
+
261
+ const text = header + trimmedVerdicts + footer;
262
+ const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}`;
263
+ window.open(shareUrl, "_blank", "width=600,height=400");
264
+ }
265
+
266
+ shareXBtn.addEventListener("click", shareOnX);
267
+
268
  /* --- Copy to clipboard --- */
269
 
270
  function buildMarkdownExport() {
 
345
  });
346
  issueBadge.hidden = true;
347
  copyBtn.hidden = true;
348
+ shareXBtn.hidden = true;
349
  fullMarkdown = "";
350
 
351
  if (!url) { showInputError("Please enter a GitHub file URL."); return; }
 
390
  const counts = countIssuePriorities(markdown);
391
  renderIssueBadge(counts);
392
  copyBtn.hidden = false;
393
+ shareXBtn.hidden = false;
394
  });
395
 
396
  source.addEventListener("error", (e) => {
public/index.html CHANGED
@@ -267,6 +267,11 @@
267
  <button class="tab" data-section="security">Security</button>
268
  <button class="tab" data-section="suggestions">Suggestions</button>
269
  <button class="tab" data-section="verdicts">Verdicts</button>
 
 
 
 
 
270
  <button type="button" id="copy-btn" hidden>Copy Review</button>
271
  </nav>
272
  <div id="tab-content" class="tab-content"></div>
 
267
  <button class="tab" data-section="security">Security</button>
268
  <button class="tab" data-section="suggestions">Suggestions</button>
269
  <button class="tab" data-section="verdicts">Verdicts</button>
270
+ <button type="button" id="share-x-btn" hidden title="Share on X">
271
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
272
+ <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>
273
+ </svg>
274
+ </button>
275
  <button type="button" id="copy-btn" hidden>Copy Review</button>
276
  </nav>
277
  <div id="tab-content" class="tab-content"></div>
public/style.css CHANGED
@@ -493,10 +493,34 @@ h1 {
493
  color: var(--text-muted);
494
  }
495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  /* ---------- Copy Button ---------- */
497
 
498
  #copy-btn {
499
- margin-left: auto;
500
  padding: 6px 14px;
501
  font-size: 0.82rem;
502
  font-weight: 500;
 
493
  color: var(--text-muted);
494
  }
495
 
496
+ /* ---------- Share on X Button ---------- */
497
+
498
+ #share-x-btn {
499
+ margin-left: auto;
500
+ padding: 6px 10px;
501
+ color: var(--text-muted);
502
+ background: var(--surface);
503
+ border: 1px solid var(--border);
504
+ border-radius: var(--radius);
505
+ cursor: pointer;
506
+ transition: all 0.15s;
507
+ display: inline-flex;
508
+ align-items: center;
509
+ }
510
+
511
+ #share-x-btn:hover {
512
+ color: var(--text);
513
+ border-color: var(--accent);
514
+ }
515
+
516
+ #share-x-btn:active {
517
+ background: var(--accent);
518
+ color: #fff;
519
+ }
520
+
521
  /* ---------- Copy Button ---------- */
522
 
523
  #copy-btn {
 
524
  padding: 6px 14px;
525
  font-size: 0.82rem;
526
  font-weight: 500;