GeezerVison is showing github.com — fix(web): chat tables open at the right size instead of collapsed and… · pingdotgg/t3code@eb751fa
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/MarkdownExternalLink.tsx +12-6Lines changed: 12 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,13 +54,19 @@ function leadingExternalLinkTextLength(text: string): number { | 54 | 54 | return Math.min(text.length, 1); | 55 | 55 | } | 56 | 56 |
| | 57 | +// Long words such as URLs can break after any character so they fit narrow | | 58 | +// table columns. Short ones, like a PR number, stay whole. | 57 | 59 | function breakableExternalLinkText(text: string): ReactNode[] { | 58 | | - return Array.from(text, (character, index) => ( | 59 | | - <Fragment key={`${index}:${character}`}> | 60 | | - {character} | 61 | | - <wbr /> | 62 | | - </Fragment> | 63 | | - )); | | 60 | + return Array.from(text.matchAll(/\s+|\S+/g), ({ 0: word, index: start }) => | | 61 | + word.length <= 16 | | 62 | + ? word | | 63 | + : Array.from(word, (character, offset) => ( | | 64 | + <Fragment key={`${start + offset}:${character}`}> | | 65 | + {character} | | 66 | + <wbr /> | | 67 | + </Fragment> | | 68 | + )), | | 69 | + ); | 64 | 70 | } | 65 | 71 |
| 66 | 72 | export function MarkdownExternalLinkContent({ | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/MarkdownTable.tsx +4-28Lines changed: 4 additions & 28 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { Check, Copy, Maximize2, Minimize2 } from "lucide"; | 2 | | -import { useRef, useState, type ComponentProps } from "react"; | | 1 | +import { Check, Copy } from "lucide"; | | 2 | +import { useRef, type ComponentProps } from "react"; | 3 | 3 |
| 4 | 4 | import { useCopyToClipboard } from "../../hooks/useCopyToClipboard"; | 5 | | -import { getClientSettings } from "../../hooks/useSettings"; | 6 | 5 | import { | 7 | 6 | serializeTableElementToCsv, | 8 | 7 | serializeTableElementToMarkdown, | @@ -16,13 +15,11 @@ import { reportMarkdownActionFailure } from "./markdownActionFailure"; | 16 | 15 |
| 17 | 16 | export function MarkdownTable({ children, ...props }: ComponentProps<"table">) { | 18 | 17 | const containerRef = useRef<HTMLDivElement | null>(null); | 19 | | - const [expanded, setExpanded] = useState(() => getClientSettings().wordWrap); | 20 | 18 | const { copyToClipboard, isCopied: copied } = useCopyToClipboard<"markdown" | "csv">({ | 21 | 19 | timeout: 1200, | 22 | 20 | onError: (cause, format) => | 23 | 21 | reportMarkdownActionFailure({ operation: "copy-table", format }, cause), | 24 | 22 | }); | 25 | | - const expandLabel = expanded ? "Collapse table cells" : "Expand table cells"; | 26 | 23 | const copyLabel = copied ? "Copied" : "Copy table"; | 27 | 24 |
| 28 | 25 | const handleCopy = (format: "markdown" | "csv") => { | @@ -37,33 +34,12 @@ export function MarkdownTable({ children, ...props }: ComponentProps<"table">) { | 37 | 34 | }; | 38 | 35 |
| 39 | 36 | return ( | 40 | | - <div | 41 | | - ref={containerRef} | 42 | | - className="chat-markdown-table-container" | 43 | | - data-expanded={expanded ? "true" : "false"} | 44 | | - > | | 37 | + <div ref={containerRef} className="chat-markdown-table-container"> | 45 | 38 | <ScrollArea radius="none" chainVerticalScroll scrollFade className="w-full max-w-full"> | 46 | 39 | <table {...props}>{children}</table> | 47 | 40 | </ScrollArea> | 48 | 41 | {/* Stays within the row's px-1: the chat lane clips sideways overflow. */} | 49 | | - <div className="mt-0.5 -mx-1 flex items-center justify-between select-none"> | 50 | | - <Tooltip> | 51 | | - <TooltipTrigger | 52 | | - render={ | 53 | | - <Button | 54 | | - type="button" | 55 | | - variant={expanded ? "secondary" : "ghost-muted"} | 56 | | - size="icon-xs" | 57 | | - aria-pressed={expanded} | 58 | | - onClick={() => setExpanded((value) => !value)} | 59 | | - aria-label={expandLabel} | 60 | | - /> | 61 | | - } | 62 | | - > | 63 | | - <MorphIcon className="size-3" icon={expanded ? Minimize2 : Maximize2} /> | 64 | | - </TooltipTrigger> | 65 | | - <TooltipPopup side="top">{expandLabel}</TooltipPopup> | 66 | | - </Tooltip> | | 42 | + <div className="mt-0.5 -mx-1 flex items-center justify-end select-none"> | 67 | 43 | <Menu> | 68 | 44 | <Tooltip> | 69 | 45 | <TooltipTrigger | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/MessagesTimeline.tsx +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1221,7 +1221,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | 1221 | 1221 | > | 1222 | 1222 | <div | 1223 | 1223 | ref={observeLaneWidth} | 1224 | | - className="@container/chat-lane chat-content-lane overflow-x-clip" | | 1224 | + className="chat-content-lane overflow-x-clip" | 1225 | 1225 | data-timeline-root="true" | 1226 | 1226 | > | 1227 | 1227 | <AudioPreviewUnmountContext value={onAudioUnmount}> | @@ -1241,10 +1241,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | 1241 | 1241 | {unmatchedPendingApprovals.size > 0 ? ( | 1242 | 1242 | <TimelineRowCtx value={sharedState}> | 1243 | 1243 | <div className="messages-timeline-row-frame"> | 1244 | | - <div | 1245 | | - className="@container/chat-lane chat-content-lane overflow-x-clip" | 1246 | | - data-timeline-root="true" | 1247 | | - > | | 1244 | + <div className="chat-content-lane overflow-x-clip" data-timeline-root="true"> | 1248 | 1245 | <WorkLogBlock> | 1249 | 1246 | {[...unmatchedPendingApprovals.values()].map((approval) => ( | 1250 | 1247 | <TimelinePendingApprovalRow key={approval.requestId} approval={approval} /> | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/TypographySettings.tsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -235,7 +235,7 @@ function WordWrapRow() { | 235 | 235 | return ( | 236 | 236 | <SettingsRow | 237 | 237 | {...searchableSetting("word-wrap")} | 238 | | - description="Wrap long lines in code blocks, tables, diffs, and file previews by default." | | 238 | + description="Wrap long lines in code blocks, diffs, and file previews by default." | 239 | 239 | resetAction={ | 240 | 240 | settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ( | 241 | 241 | <SettingResetButton | @@ -248,7 +248,7 @@ function WordWrapRow() { | 248 | 248 | <Switch | 249 | 249 | checked={settings.wordWrap} | 250 | 250 | onCheckedChange={(checked) => updateSettings({ wordWrap: Boolean(checked) })} | 251 | | - aria-label="Wrap code, tables, diffs, and file previews by default" | | 251 | + aria-label="Wrap code, diffs, and file previews by default" | 252 | 252 | /> | 253 | 253 | } | 254 | 254 | /> | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/settingsSearch.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -380,7 +380,7 @@ export const SETTINGS_SEARCH_ITEMS = [ | 380 | 380 | id: "word-wrap", | 381 | 381 | title: "Word wrap", | 382 | 382 | to: "/settings/appearance", | 383 | | - searchTerms: ["long lines code blocks tables diffs file previews"], | | 383 | + searchTerms: ["long lines code blocks diffs file previews"], | 384 | 384 | }, | 385 | 385 | { | 386 | 386 | id: "composer-context", | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/index.css +9-37Lines changed: 9 additions & 37 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2193,14 +2193,13 @@ code { | 2193 | 2193 | } | 2194 | 2194 | } | 2195 | 2195 |
| 2196 | | -/* Diagnostics-style tables: row separators only, uppercase headers, and a | 2197 | | - scroll-fade container for horizontal overflow. The root chat-markdown | 2198 | | - wrapping rules (overflow-wrap: anywhere) would let columns shrink to single | 2199 | | - characters and defeat the overflow — restore word-boundary wrapping so the | 2200 | | - min column width is the longest word. */ | | 2196 | +/* Diagnostics-style tables: row separators only, and a scroll-fade container | | 2197 | + for horizontal overflow. Cells wrap and the table fits its lane. The root | | 2198 | + chat-markdown wrapping rules (overflow-wrap: anywhere) would let columns | | 2199 | + shrink to single characters, so restore word-boundary wrapping: the min | | 2200 | + column width is the longest word, and only wider content scrolls. */ | 2201 | 2201 | .chat-markdown table { | 2202 | 2202 | width: 100%; | 2203 | | - min-width: max-content; | 2204 | 2203 | border-collapse: collapse; | 2205 | 2204 | overflow-wrap: normal; | 2206 | 2205 | word-break: normal; | @@ -2230,48 +2229,21 @@ code { | 2230 | 2229 | border-bottom: 1px solid color-mix(in srgb, var(--contrast-border) 60%, transparent); | 2231 | 2230 | padding-block: 0.55rem; | 2232 | 2231 | font-weight: 600; | 2233 | | - white-space: nowrap; | 2234 | 2232 | } | 2235 | 2233 |
| 2236 | 2234 | .chat-markdown tbody td { | 2237 | 2235 | border-bottom: 1px solid color-mix(in srgb, var(--contrast-border) 60%, transparent); | 2238 | 2236 | } | 2239 | 2237 |
| 2240 | | -/* Collapsed (default): single-line cells truncate so arbitrary chat content | 2241 | | - cannot blow the column out; the footer toggle expands cells to wrap. */ | 2242 | | -.chat-markdown .chat-markdown-table-container[data-expanded="false"] th, | 2243 | | -.chat-markdown .chat-markdown-table-container[data-expanded="false"] td { | 2244 | | - overflow: hidden; | | 2238 | +/* Caps a long path, URL, or chip at 24rem; text past the cap wraps. */ | | 2239 | +.chat-markdown :is(th, td) { | 2245 | 2240 | max-width: 24rem; | 2246 | | - text-overflow: ellipsis; | 2247 | | - white-space: nowrap; | 2248 | | -} | 2249 | | - | 2250 | | -.chat-markdown .chat-markdown-table-container[data-expanded="true"] td { | 2251 | | - max-width: 24rem; | 2252 | | - overflow-wrap: anywhere; | 2253 | | -} | 2254 | | - | 2255 | | -/* Fit expanded tables to wide timeline lanes; narrow lanes keep horizontal | 2256 | | - scrolling so prose columns remain readable. */ | 2257 | | -@container chat-lane (min-width: 36rem) { | 2258 | | - .chat-markdown .chat-markdown-table-container[data-expanded="true"] table { | 2259 | | - min-width: 0; | 2260 | | - } | 2261 | | - | 2262 | | - .chat-markdown .chat-markdown-table-container[data-expanded="true"] th { | 2263 | | - white-space: normal; | 2264 | | - } | 2265 | | - | 2266 | | - .chat-markdown .chat-markdown-table-container[data-expanded="true"] td { | 2267 | | - overflow-wrap: break-word; | 2268 | | - } | | 2241 | + overflow-wrap: break-word; | 2269 | 2242 | } | 2270 | 2243 |
| 2271 | 2244 | /* Formula cells keep their natural width and scroll with the table. */ | 2272 | | -.chat-markdown .chat-markdown-table-container td:has([data-markdown-math]) { | | 2245 | +.chat-markdown :is(th, td):has([data-markdown-math]) { | 2273 | 2246 | max-width: none; | 2274 | | - overflow: visible; | 2275 | 2247 | } | 2276 | 2248 |
| 2277 | 2249 | :root { | |
|