diff --git a/DESIGN.md b/DESIGN.md index 1cb2aab6e5..cf70beb072 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -271,7 +271,7 @@ Quiet, rectangular, decisive. ### Inputs / Fields - **Composer:** borderless, no visible field chrome: a 17px textarea ("What did you ship?", max 4,000) that grows with content. Its state is carried by the graph: the staged node is hollow until the body has a character, then fills with the author's lane; the tail below it is a dashed Rail Gray line. A mono countdown sits left of the "Commit" button; ⌘/Ctrl+Enter commits. -- **Preview:** an eye icon button after the image picker (Blue Wash with Commit Blue icon while pressed) swaps the textarea for the draft rendered as the posted commit at 15px, in the same spot and never shorter than the textarea, so the counter row stays put. Attached images show as the posted grid, and the URL that will unfurl sits in a dashed hairline box with a mono URL and "Unfurls into a link card after you commit." ⌘/Ctrl+Shift+P toggles it; Esc returns to writing; ⌘/Ctrl+Enter still commits. +- **Preview:** an eye icon button after the image picker (Blue Wash with Commit Blue icon while pressed) swaps the textarea for the draft rendered as the posted commit at 15px, in the same spot and never shorter than the textarea, so the counter row stays put. Attached images show as the posted grid, and the URL that will unfurl sits in a dashed hairline box with a mono URL and "Unfurls into a link card after you commit." (a /dev/null commit shows the /dev/null mark, mono `handle/hash`, and "Unfurls into a commit card after you commit."). ⌘/Ctrl+Shift+P toggles it; Esc returns to writing; ⌘/Ctrl+Enter still commits. - **Stash:** unsent text in the composer and in each reply composer is kept in `localStorage` per signed-in user (cleared on commit, when emptied, and on log out). When a draft comes back after a reload or navigation, a quiet mono `stash@{0}` (title "Restored your unsent draft") sits at the left of the counter row with a muted `drop` text button that discards it. Merely typing never shows it. A thread with a stashed reply prints a muted 11px mono `stash@{0}` after its "Reply" action; Cancel and Escape close the reply composer but keep the stash. Neither element is blue. - **Read-only fields (settings):** a hairline-bordered 8px-radius list, mono keys in a 6.5rem column, values in sans; missing values print a mono `null`. - **Color picker (settings):** a live preview row (rail node, 48px avatar with the lane ring, lane-dotted handle) above a radio group of seven 28px swatches with sans captions: a dashed "Auto" swatch showing the hashed lane, then the six lanes. The checked swatch gets the 2px lane ring offset from the surface; picking another swatch slides the ring over to it and crossfades the preview into the new lane; focus shows the standard focus ring on the whole option. Saved with a primary "Save color" button, disabled until the choice changes. Only the six lanes are offered so light/dark lifts and contrast keep working. @@ -341,6 +341,8 @@ A deleted commit that still has visible replies keeps its place so the conversat ### Quotes A quote is a regular commit row with the quoted commit embedded under its body: a hairline-bordered, 8px-rounded block (like a link preview, no lane color) with a 20px avatar, name (600), mono handle, and mono relative time on one line, then the body at 15px, pre-wrapped and clamped to six lines. The whole block is one link to the quoted commit's page and tints Accent on hover/focus; it embeds one level only. A deleted quoted commit is a dashed block with a mono `[deleted]` token and "This commit was deleted."; one the viewer cannot see reads `[unavailable]` and "This commit isn't available.", with no author, time, or body. "Quote" sits in the action row after the star (icon only on phones) and opens a dialog titled "Quote @handle": the viewer's avatar, a 17px textarea ("Add your take") with its own stash, the quoted block as a static preview, a counter, Cancel, and Quote (⌘/Ctrl+Enter). It is hidden wherever the star is. +A link card for a /dev/null commit reads as that commit rather than a web page: the /dev/null mark and mono `handle/hash` where other cards put the site name, then the body at 15px in Foreground, clamped to three lines. Its thumbnail is the commit's own first image, never the drawn link preview of the commit, and the card opens the commit in place instead of a new tab. + ### Commit Page Every commit has a page at `/@handle/commits/{id}`, reached from its relative time or short hash (both links), the "↳ replying to @handle" label, or Enter on a focused commit. A sticky header reads "Commit" with the mono short hash and a copy-link icon on the right. Visible ancestors (up to 20) stack above as regular commit rows on one continuous rail, without delete, with deleted ones as tombstones; the focused commit sits last with a 17px body, a mono "time · date · commit hash" line, and its replies already expanded. A deleted commit's own page is a 404. diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index 4cf327f296..e846ea5ec3 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -299,7 +299,7 @@ Sources: [image picker](resources/js/components/commit-image-picker.tsx), [image Each link in a commit or reply counts as at most **23 characters** toward the 4,000-character allowance; shorter links count at their actual length. This also applies to quotes, scheduled commits, previews, and terminal and app submissions. The full URL is stored and followed directly, not through a redirect service. Prose URLs longer than **2,048 characters** are rejected, including the inferred `https://` scheme for bare domains. Code still counts literally toward the 4,000-character allowance. Bodies are additionally capped at 40,000 raw characters to bound storage and processing. Private messages and issue drafts keep their existing literal character limits. -URLs and bare domains in commits and replies become clickable links. Long URLs are shortened visually; hover reveals the full destination. GitHub repository links show as `owner/repo`, and issue or pull request links as `owner/repo#123`, with the GitHub mark. Links to /dev/null commits show as the author's username and a short hash. Code keeps its literal text. The first link normally gets a preview card with available title, description, and image. In the commit, reply, and quote composers, choose another link from the body or choose no card; terminal commits and app commits always use the first link. Missing site metadata may leave a link without a rich preview. Different ways of writing the same link share one card: the host's case, a default port, a lone trailing `/`, the highlight a browser adds to a link (`#:~:text=`), and tracking parameters such as `utm_*`, `fbclid` or YouTube's `si` don't make a new one, and a few sites share one card across their addresses, so `youtube.com/watch?v=…` and `youtu.be/…` show the same card, as do `twitter.com` and `x.com`. Any other `#fragment` stays part of the link, so a link to a news entry, a line of code or a comment keeps a card of its own. The card links to that shared address, while the commit keeps the link exactly as written. +URLs and bare domains in commits and replies become clickable links. Long URLs are shortened visually; hover reveals the full destination. GitHub repository links show as `owner/repo`, and issue or pull request links as `owner/repo#123`, with the GitHub mark. Links to /dev/null commits show as the author's username and a short hash, and their preview card shows the /dev/null mark, the same username and hash, the commit's text, and its own first image if it has one, opening the commit's page in the same tab. Code keeps its literal text. The first link normally gets a preview card with available title, description, and image. In the commit, reply, and quote composers, choose another link from the body or choose no card; terminal commits and app commits always use the first link. Missing site metadata may leave a link without a rich preview. Different ways of writing the same link share one card: the host's case, a default port, a lone trailing `/`, the highlight a browser adds to a link (`#:~:text=`), and tracking parameters such as `utm_*`, `fbclid` or YouTube's `si` don't make a new one, and a few sites share one card across their addresses, so `youtube.com/watch?v=…` and `youtu.be/…` show the same card, as do `twitter.com` and `x.com`. Any other `#fragment` stays part of the link, so a link to a news entry, a line of code or a comment keeps a card of its own. The card links to that shared address, while the commit keeps the link exactly as written. Supported links can also show click-to-play embedded players: YouTube, Vimeo, Loom, Twitch, Spotify, SoundCloud, Apple Music, Suno, CodePen, and asciinema. Only the link that gets the card can show a player, so choosing no card means no player. Embeds depend on server configuration and the linked URL being supported. Third-party player content loads only after you press play; those providers have their own privacy policies. This is embedding a link, not uploading a video or audio file to /dev/null. diff --git a/resources/js/components/composer-preview.tsx b/resources/js/components/composer-preview.tsx index b8c98631a0..334b09d568 100644 --- a/resources/js/components/composer-preview.tsx +++ b/resources/js/components/composer-preview.tsx @@ -5,6 +5,7 @@ import { useEffect, useEffectEvent, useId, useRef, useState } from 'react'; import { toast } from 'sonner'; import CommitPreviewController from '@/actions/App/Http/Controllers/CommitPreviewController'; import { ActionTooltip } from '@/components/action-tooltip'; +import AppLogoIcon from '@/components/app-logo-icon'; import { CommitBody } from '@/components/commit-body'; import { objectUrlFor } from '@/components/commit-image-picker'; import { CommitImages } from '@/components/commit-images'; @@ -15,7 +16,8 @@ import { Button } from '@/components/ui/button'; import { useNow } from '@/hooks/use-now'; import { bodySegments, hasCodeBlock } from '@/lib/code'; import { hasModKey, useKeyLabels } from '@/lib/keyboard'; -import { cn } from '@/lib/utils'; +import { commitLinkTo } from '@/lib/urls'; +import { cn, shortHash } from '@/lib/utils'; import type { BodySegment } from '@/types'; import type { GuildMentions } from '@/types/guild'; @@ -300,6 +302,8 @@ export function ComposerPreviewBody({ url: string | null; className?: string; }) { + const commitLink = url ? commitLinkTo(url) : null; + return (
- {url.replace(/^https?:\/\//i, '')} + {commitLink + ? `${commitLink.handle}/${shortHash(commitLink.commit)}` + : url.replace(/^https?:\/\//i, '')}
- Unfurls into a link card after you commit. + Unfurls into a {commitLink ? 'commit' : 'link'} card + after you commit.
2 more commits
); + + assert.match( + body, + new RegExp( + `id="app">2 more commits<\/p><\/div><\/div>$/);
+});
+
+test('leaves every other link card as it was', async () => {
+ const body = await render({
+ ...commitCard,
+ url: 'https://laravel.com',
+ title: 'Laravel',
+ description: 'The PHP framework for web artisans.',
+ image_url: 'https://laravel.com/og.png',
+ site_name: 'Laravel',
+ });
+
+ assert.match(
+ body,
+ /]*href="https:\/\/laravel.com"[^>]*target="_blank"/,
+ );
+ assert.match(body, />Laravel);
+ assert.match(body, /]*src="https:\/\/laravel.com\/og.png"/);
+});
+
+test('waits for a dev/null commit link card without a thumbnail', async () => {
+ const pending = await render({ ...commitCard, is_pending: true });
+ const other = await render({
+ ...commitCard,
+ url: 'https://laravel.com',
+ is_pending: true,
+ });
+
+ assert.match(pending, /data-test="link-preview-skeleton"/);
+ assert.doesNotMatch(pending, /size-20/);
+ assert.match(other, /size-20/);
+});