From 338393c0162452777ce40f4dbc75eefe4667a3e6 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 19 Feb 2026 08:44:17 -0600 Subject: [PATCH] fix(app): accordion styles --- packages/ui/src/components/accordion.css | 49 +- packages/ui/src/components/message-part.css | 1 - packages/ui/src/components/session-review.css | 72 +- packages/ui/src/components/session-review.tsx | 682 +++++++++--------- packages/ui/src/components/session-turn.css | 43 -- packages/ui/src/components/session-turn.tsx | 130 ++-- .../components/sticky-accordion-header.css | 16 +- 7 files changed, 455 insertions(+), 538 deletions(-) diff --git a/packages/ui/src/components/accordion.css b/packages/ui/src/components/accordion.css index 7bf287fe5..b4d6323d0 100644 --- a/packages/ui/src/components/accordion.css +++ b/packages/ui/src/components/accordion.css @@ -2,7 +2,7 @@ display: flex; flex-direction: column; align-items: flex-start; - gap: 8px; + gap: 0px; align-self: stretch; [data-slot="accordion-item"] { @@ -11,7 +11,11 @@ flex-direction: column; align-items: flex-start; align-self: stretch; - overflow: clip; + overflow: visible; + + & + [data-slot="accordion-item"] { + margin-top: -1px; + } [data-slot="accordion-header"] { width: 100%; @@ -31,9 +35,10 @@ cursor: default; user-select: none; - background-color: var(--surface-base); + background-color: var(--background-stronger); border: 1px solid var(--border-weak-base); - border-radius: var(--radius-md); + border-radius: 0; + box-shadow: none; overflow: clip; color: var(--text-strong); transition: background-color 0.15s ease; @@ -47,7 +52,10 @@ letter-spacing: var(--letter-spacing-normal); &:hover { - background-color: var(--surface-base); + background-color: var(--surface-base-hover); + } + &:active { + background-color: var(--surface-base-active); } &:focus-visible { outline: none; @@ -58,23 +66,40 @@ } } - &[data-expanded] { - [data-slot="accordion-trigger"] { - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; + &:first-child { + [data-slot="accordion-header"] [data-slot="accordion-trigger"] { + border-top-left-radius: var(--radius-lg); + border-top-right-radius: var(--radius-lg); } + } + &:last-child:not([data-expanded]) { + [data-slot="accordion-header"] [data-slot="accordion-trigger"] { + border-bottom-left-radius: var(--radius-lg); + border-bottom-right-radius: var(--radius-lg); + } + } + + &[data-expanded] { [data-slot="accordion-content"] { border: 1px solid var(--border-weak-base); - border-top: none; - border-bottom-left-radius: var(--radius-md); - border-bottom-right-radius: var(--radius-md); + border-top: 0; + background-color: var(--background-stronger); + } + } + + &:last-child[data-expanded] { + [data-slot="accordion-content"] { + border-bottom-left-radius: var(--radius-lg); + border-bottom-right-radius: var(--radius-lg); } } [data-slot="accordion-content"] { overflow: hidden; width: 100%; + border: 0; + background-color: transparent; } } } diff --git a/packages/ui/src/components/message-part.css b/packages/ui/src/components/message-part.css index d123847cb..1b5694682 100644 --- a/packages/ui/src/components/message-part.css +++ b/packages/ui/src/components/message-part.css @@ -1288,7 +1288,6 @@ } [data-component="apply-patch-file-diff"] { - border-top: 1px solid var(--border-weaker-base); max-height: 420px; overflow-y: auto; scrollbar-width: none; diff --git a/packages/ui/src/components/session-review.css b/packages/ui/src/components/session-review.css index bef8f4f0e..ec1698d29 100644 --- a/packages/ui/src/components/session-review.css +++ b/packages/ui/src/components/session-review.css @@ -1,7 +1,7 @@ [data-component="session-review"] { display: flex; flex-direction: column; - gap: 8px; + gap: 0px; height: 100%; overflow-y: auto; scrollbar-width: none; @@ -19,7 +19,8 @@ top: 0; z-index: 20; background-color: var(--background-stronger); - height: 32px; + height: 40px; + padding-bottom: 8px; flex-shrink: 0; display: flex; justify-content: space-between; @@ -57,70 +58,13 @@ } [data-component="sticky-accordion-header"] { - top: 40px; + --sticky-accordion-top: 40px; } - [data-component="sticky-accordion-header"][data-expanded]::before, - [data-slot="accordion-item"][data-expanded] [data-component="sticky-accordion-header"]::before { - top: -40px; - } - - [data-slot="session-review-diffs-group"] { - background-color: var(--background-stronger); - border-radius: var(--radius-lg); - border: 1px solid var(--border-weak-base); - overflow: clip; - - [data-component="accordion"] { - gap: 0; - } - - [data-component="accordion"] [data-slot="accordion-item"] { - overflow: visible; - } - - [data-component="accordion"] - [data-slot="accordion-item"] - [data-slot="accordion-header"] - [data-slot="accordion-trigger"] { - border: 0; - border-radius: 0; - box-shadow: none; - background-color: transparent; - - &:hover { - background-color: var(--surface-base-hover); - } - - &:active { - background-color: var(--surface-base-active); - } - } - - [data-component="accordion"] - [data-slot="accordion-item"] - + [data-slot="accordion-item"] - [data-slot="accordion-header"] - [data-slot="accordion-trigger"] { - border-top: 1px solid var(--border-weak-base); - } - - [data-component="accordion"] [data-slot="accordion-item"][data-expanded] [data-slot="accordion-content"] { - border: 0; - border-top: 1px solid var(--border-weak-base); - border-radius: 0; - } - - [data-component="sticky-accordion-header"][data-expanded]::before, - [data-slot="accordion-item"][data-expanded] [data-component="sticky-accordion-header"]::before { - top: 0; - } - - [data-slot="session-review-accordion-item"][data-selected] - [data-slot="accordion-header"] - [data-slot="accordion-trigger"] { - background-color: var(--surface-base-active); - } + [data-slot="session-review-accordion-item"][data-selected] + [data-slot="accordion-header"] + [data-slot="accordion-trigger"] { + background-color: var(--surface-base-active); } [data-slot="accordion-item"] { diff --git a/packages/ui/src/components/session-review.tsx b/packages/ui/src/components/session-review.tsx index 815d8129d..fd85fb485 100644 --- a/packages/ui/src/components/session-review.tsx +++ b/packages/ui/src/components/session-review.tsx @@ -320,395 +320,393 @@ export const SessionReview = (props: SessionReviewProps) => {
-
- - - {(diff) => { - let wrapper: HTMLDivElement | undefined + + + {(diff) => { + let wrapper: HTMLDivElement | undefined - const expanded = createMemo(() => open().includes(diff.file)) - const [force, setForce] = createSignal(false) + const expanded = createMemo(() => open().includes(diff.file)) + const [force, setForce] = createSignal(false) - const comments = createMemo(() => (props.comments ?? []).filter((c) => c.file === diff.file)) - const commentedLines = createMemo(() => comments().map((c) => c.selection)) + const comments = createMemo(() => (props.comments ?? []).filter((c) => c.file === diff.file)) + const commentedLines = createMemo(() => comments().map((c) => c.selection)) - const beforeText = () => (typeof diff.before === "string" ? diff.before : "") - const afterText = () => (typeof diff.after === "string" ? diff.after : "") - const changedLines = () => diff.additions + diff.deletions + const beforeText = () => (typeof diff.before === "string" ? diff.before : "") + const afterText = () => (typeof diff.after === "string" ? diff.after : "") + const changedLines = () => diff.additions + diff.deletions - const tooLarge = createMemo(() => { - if (!expanded()) return false - if (force()) return false - if (isImageFile(diff.file)) return false - return changedLines() > MAX_DIFF_CHANGED_LINES - }) + const tooLarge = createMemo(() => { + if (!expanded()) return false + if (force()) return false + if (isImageFile(diff.file)) return false + return changedLines() > MAX_DIFF_CHANGED_LINES + }) - const isAdded = () => diff.status === "added" || (beforeText().length === 0 && afterText().length > 0) - const isDeleted = () => - diff.status === "deleted" || (afterText().length === 0 && beforeText().length > 0) - const isImage = () => isImageFile(diff.file) - const isAudio = () => isAudioFile(diff.file) + const isAdded = () => diff.status === "added" || (beforeText().length === 0 && afterText().length > 0) + const isDeleted = () => + diff.status === "deleted" || (afterText().length === 0 && beforeText().length > 0) + const isImage = () => isImageFile(diff.file) + const isAudio = () => isAudioFile(diff.file) - const diffImageSrc = dataUrlFromValue(diff.after) ?? dataUrlFromValue(diff.before) - const [imageSrc, setImageSrc] = createSignal(diffImageSrc) - const [imageStatus, setImageStatus] = createSignal<"idle" | "loading" | "error">("idle") + const diffImageSrc = dataUrlFromValue(diff.after) ?? dataUrlFromValue(diff.before) + const [imageSrc, setImageSrc] = createSignal(diffImageSrc) + const [imageStatus, setImageStatus] = createSignal<"idle" | "loading" | "error">("idle") - const diffAudioSrc = dataUrlFromValue(diff.after) ?? dataUrlFromValue(diff.before) - const [audioSrc, setAudioSrc] = createSignal(diffAudioSrc) - const [audioStatus, setAudioStatus] = createSignal<"idle" | "loading" | "error">("idle") - const [audioMime, setAudioMime] = createSignal(undefined) + const diffAudioSrc = dataUrlFromValue(diff.after) ?? dataUrlFromValue(diff.before) + const [audioSrc, setAudioSrc] = createSignal(diffAudioSrc) + const [audioStatus, setAudioStatus] = createSignal<"idle" | "loading" | "error">("idle") + const [audioMime, setAudioMime] = createSignal(undefined) - const selectedLines = createMemo(() => { - const current = selection() - if (!current || current.file !== diff.file) return null - return current.range - }) + const selectedLines = createMemo(() => { + const current = selection() + if (!current || current.file !== diff.file) return null + return current.range + }) - const draftRange = createMemo(() => { - const current = commenting() - if (!current || current.file !== diff.file) return null - return current.range - }) + const draftRange = createMemo(() => { + const current = commenting() + if (!current || current.file !== diff.file) return null + return current.range + }) - const [draft, setDraft] = createSignal("") - const [positions, setPositions] = createSignal>({}) - const [draftTop, setDraftTop] = createSignal(undefined) + const [draft, setDraft] = createSignal("") + const [positions, setPositions] = createSignal>({}) + const [draftTop, setDraftTop] = createSignal(undefined) - const getRoot = () => { - const el = wrapper - if (!el) return + const getRoot = () => { + const el = wrapper + if (!el) return - const host = el.querySelector("diffs-container") - if (!(host instanceof HTMLElement)) return - return host.shadowRoot ?? undefined + const host = el.querySelector("diffs-container") + if (!(host instanceof HTMLElement)) return + return host.shadowRoot ?? undefined + } + + const updateAnchors = () => { + const el = wrapper + if (!el) return + + const root = getRoot() + if (!root) return + + const next: Record = {} + for (const item of comments()) { + const marker = findMarker(root, item.selection) + if (!marker) continue + next[item.id] = markerTop(el, marker) + } + setPositions(next) + + const range = draftRange() + if (!range) { + setDraftTop(undefined) + return } - const updateAnchors = () => { - const el = wrapper - if (!el) return - - const root = getRoot() - if (!root) return - - const next: Record = {} - for (const item of comments()) { - const marker = findMarker(root, item.selection) - if (!marker) continue - next[item.id] = markerTop(el, marker) - } - setPositions(next) - - const range = draftRange() - if (!range) { - setDraftTop(undefined) - return - } - - const marker = findMarker(root, range) - if (!marker) { - setDraftTop(undefined) - return - } - - setDraftTop(markerTop(el, marker)) + const marker = findMarker(root, range) + if (!marker) { + setDraftTop(undefined) + return } - const scheduleAnchors = () => { - requestAnimationFrame(updateAnchors) - } + setDraftTop(markerTop(el, marker)) + } - createEffect(() => { - comments() - scheduleAnchors() - }) + const scheduleAnchors = () => { + requestAnimationFrame(updateAnchors) + } - createEffect(() => { - const range = draftRange() - if (!range) return - setDraft("") - scheduleAnchors() - }) + createEffect(() => { + comments() + scheduleAnchors() + }) - createEffect(() => { - if (!open().includes(diff.file)) return - if (!isImage()) return - if (imageSrc()) return - if (imageStatus() !== "idle") return - if (isDeleted()) return + createEffect(() => { + const range = draftRange() + if (!range) return + setDraft("") + scheduleAnchors() + }) - const reader = props.readFile - if (!reader) return + createEffect(() => { + if (!open().includes(diff.file)) return + if (!isImage()) return + if (imageSrc()) return + if (imageStatus() !== "idle") return + if (isDeleted()) return - setImageStatus("loading") - reader(diff.file) - .then((result) => { - const src = dataUrl(result) - if (!src) { - setImageStatus("error") - return - } - setImageSrc(src) - setImageStatus("idle") - }) - .catch(() => { + const reader = props.readFile + if (!reader) return + + setImageStatus("loading") + reader(diff.file) + .then((result) => { + const src = dataUrl(result) + if (!src) { setImageStatus("error") - }) - }) + return + } + setImageSrc(src) + setImageStatus("idle") + }) + .catch(() => { + setImageStatus("error") + }) + }) - createEffect(() => { - if (!open().includes(diff.file)) return - if (!isAudio()) return - if (audioSrc()) return - if (audioStatus() !== "idle") return + createEffect(() => { + if (!open().includes(diff.file)) return + if (!isAudio()) return + if (audioSrc()) return + if (audioStatus() !== "idle") return - const reader = props.readFile - if (!reader) return + const reader = props.readFile + if (!reader) return - setAudioStatus("loading") - reader(diff.file) - .then((result) => { - const src = dataUrl(result) - if (!src) { - setAudioStatus("error") - return - } - setAudioMime(normalizeMimeType(result?.mimeType)) - setAudioSrc(src) - setAudioStatus("idle") - }) - .catch(() => { + setAudioStatus("loading") + reader(diff.file) + .then((result) => { + const src = dataUrl(result) + if (!src) { setAudioStatus("error") - }) - }) + return + } + setAudioMime(normalizeMimeType(result?.mimeType)) + setAudioSrc(src) + setAudioStatus("idle") + }) + .catch(() => { + setAudioStatus("error") + }) + }) - const handleLineSelected = (range: SelectedLineRange | null) => { - if (!props.onLineComment) return + const handleLineSelected = (range: SelectedLineRange | null) => { + if (!props.onLineComment) return - if (!range) { - setSelection(null) - return - } - - setSelection({ file: diff.file, range }) + if (!range) { + setSelection(null) + return } - const handleLineSelectionEnd = (range: SelectedLineRange | null) => { - if (!props.onLineComment) return + setSelection({ file: diff.file, range }) + } - if (!range) { - setCommenting(null) - return - } + const handleLineSelectionEnd = (range: SelectedLineRange | null) => { + if (!props.onLineComment) return - setSelection({ file: diff.file, range }) - setCommenting({ file: diff.file, range }) + if (!range) { + setCommenting(null) + return } - const openComment = (comment: SessionReviewComment) => { - setOpened({ file: comment.file, id: comment.id }) - setSelection({ file: comment.file, range: comment.selection }) - } + setSelection({ file: diff.file, range }) + setCommenting({ file: diff.file, range }) + } - const isCommentOpen = (comment: SessionReviewComment) => { - const current = opened() - if (!current) return false - return current.file === comment.file && current.id === comment.id - } + const openComment = (comment: SessionReviewComment) => { + setOpened({ file: comment.file, id: comment.id }) + setSelection({ file: comment.file, range: comment.selection }) + } - return ( - - - -
-
- -
- - {`\u202A${getDirectory(diff.file)}\u202C`} - - {getFilename(diff.file)} - - - - - -
-
-
- - -
- - {i18n.t("ui.sessionReview.change.added")} - - -
-
- - - {i18n.t("ui.sessionReview.change.removed")} - - - - - {i18n.t("ui.sessionReview.change.modified")} - - - - - -
- - - + const isCommentOpen = (comment: SessionReviewComment) => { + const current = opened() + if (!current) return false + return current.file === comment.file && current.id === comment.id + } + + return ( + + + +
+
+ +
+ + {`\u202A${getDirectory(diff.file)}\u202C`} + + {getFilename(diff.file)} + + + + +
- - - -
{ - wrapper = el - anchors.set(diff.file, el) - scheduleAnchors() - }} - > - +
- -
- {diff.file} -
-
- -
- - {i18n.t("ui.sessionReview.change.removed")} + +
+ + {i18n.t("ui.sessionReview.change.added")} +
- -
- - {imageStatus() === "loading" - ? i18n.t("ui.sessionReview.image.loading") - : i18n.t("ui.sessionReview.image.placeholder")} - -
+ + + {i18n.t("ui.sessionReview.change.removed")} + - -
-
- {i18n.t("ui.sessionReview.largeDiff.title")} -
-
- {i18n.t("ui.sessionReview.largeDiff.meta", { - limit: MAX_DIFF_CHANGED_LINES.toLocaleString(), - current: changedLines().toLocaleString(), - })} -
-
- -
-
+ + + {i18n.t("ui.sessionReview.change.modified")} + - - { - props.onDiffRendered?.() - scheduleAnchors() - }} - enableLineSelection={props.onLineComment != null} - onLineSelected={handleLineSelected} - onLineSelectionEnd={handleLineSelectionEnd} - selectedLines={selectedLines()} - commentedLines={commentedLines()} - before={{ - name: diff.file!, - contents: typeof diff.before === "string" ? diff.before : "", - }} - after={{ - name: diff.file!, - contents: typeof diff.after === "string" ? diff.after : "", - }} - /> + + - - - {(comment) => ( - setSelection({ file: comment.file, range: comment.selection })} - onClick={() => { - if (isCommentOpen(comment)) { - setOpened(null) - return - } - - openComment(comment) - }} - open={isCommentOpen(comment)} - comment={comment.comment} - selection={selectionLabel(comment.selection)} - /> - )} - - - - {(range) => ( - - setCommenting(null)} - onSubmit={(comment) => { - props.onLineComment?.({ - file: diff.file, - selection: range(), - comment, - preview: selectionPreview(diff, range()), - }) - setCommenting(null) - }} - /> - - )} - - + + + +
- - - ) - }} - - -
+ + + +
{ + wrapper = el + anchors.set(diff.file, el) + scheduleAnchors() + }} + > + + + +
+ {diff.file} +
+
+ +
+ + {i18n.t("ui.sessionReview.change.removed")} + +
+
+ +
+ + {imageStatus() === "loading" + ? i18n.t("ui.sessionReview.image.loading") + : i18n.t("ui.sessionReview.image.placeholder")} + +
+
+ +
+
+ {i18n.t("ui.sessionReview.largeDiff.title")} +
+
+ {i18n.t("ui.sessionReview.largeDiff.meta", { + limit: MAX_DIFF_CHANGED_LINES.toLocaleString(), + current: changedLines().toLocaleString(), + })} +
+
+ +
+
+
+ + { + props.onDiffRendered?.() + scheduleAnchors() + }} + enableLineSelection={props.onLineComment != null} + onLineSelected={handleLineSelected} + onLineSelectionEnd={handleLineSelectionEnd} + selectedLines={selectedLines()} + commentedLines={commentedLines()} + before={{ + name: diff.file!, + contents: typeof diff.before === "string" ? diff.before : "", + }} + after={{ + name: diff.file!, + contents: typeof diff.after === "string" ? diff.after : "", + }} + /> + +
+ + + {(comment) => ( + setSelection({ file: comment.file, range: comment.selection })} + onClick={() => { + if (isCommentOpen(comment)) { + setOpened(null) + return + } + + openComment(comment) + }} + open={isCommentOpen(comment)} + comment={comment.comment} + selection={selectionLabel(comment.selection)} + /> + )} + + + + {(range) => ( + + setCommenting(null)} + onSubmit={(comment) => { + props.onLineComment?.({ + file: diff.file, + selection: range(), + comment, + preview: selectionPreview(diff, range()), + }) + setCommenting(null) + }} + /> + + )} + +
+
+
+ + ) + }} + +
diff --git a/packages/ui/src/components/session-turn.css b/packages/ui/src/components/session-turn.css index f952f6aad..902c85a8b 100644 --- a/packages/ui/src/components/session-turn.css +++ b/packages/ui/src/components/session-turn.css @@ -129,49 +129,6 @@ flex-direction: column; } - [data-slot="session-turn-diffs-group"] { - background-color: var(--background-stronger); - border-radius: var(--radius-lg); - border: 1px solid var(--border-weak-base); - overflow: clip; - - [data-component="accordion"] { - gap: 0; - } - - [data-component="accordion"] - [data-slot="accordion-item"] - [data-slot="accordion-header"] - [data-slot="accordion-trigger"] { - border: 0; - border-radius: 0; - box-shadow: none; - background-color: transparent; - - &:hover { - background-color: var(--surface-base-hover); - } - - &:active { - background-color: var(--surface-base-active); - } - } - - [data-component="accordion"] - [data-slot="accordion-item"] - + [data-slot="accordion-item"] - [data-slot="accordion-header"] - [data-slot="accordion-trigger"] { - border-top: 1px solid var(--border-weak-base); - } - - [data-component="accordion"] [data-slot="accordion-item"][data-expanded] [data-slot="accordion-content"] { - border: 0; - border-top: 1px solid var(--border-weak-base); - border-radius: 0; - } - } - [data-slot="session-turn-diff-trigger"] { display: flex; align-items: center; diff --git a/packages/ui/src/components/session-turn.tsx b/packages/ui/src/components/session-turn.tsx index e0f934cd5..046312738 100644 --- a/packages/ui/src/components/session-turn.tsx +++ b/packages/ui/src/components/session-turn.tsx @@ -315,78 +315,76 @@ export function SessionTurn(
-
- setExpanded(Array.isArray(value) ? value : value ? [value] : [])} - > - - {(diff) => { - const active = createMemo(() => expanded().includes(diff.file)) - const [visible, setVisible] = createSignal(false) + setExpanded(Array.isArray(value) ? value : value ? [value] : [])} + > + + {(diff) => { + const active = createMemo(() => expanded().includes(diff.file)) + const [visible, setVisible] = createSignal(false) - createEffect( - on( - active, - (value) => { - if (!value) { - setVisible(false) - return - } + createEffect( + on( + active, + (value) => { + if (!value) { + setVisible(false) + return + } - requestAnimationFrame(() => { - if (!active()) return - setVisible(true) - }) - }, - { defer: true }, - ), - ) + requestAnimationFrame(() => { + if (!active()) return + setVisible(true) + }) + }, + { defer: true }, + ), + ) - return ( - - - -
- - - - {`\u202A${getDirectory(diff.file)}\u202C`} - - - - {getFilename(diff.file)} + return ( + + + +
+ + + + {`\u202A${getDirectory(diff.file)}\u202C`} + + + {getFilename(diff.file)} + + +
+ + + + + -
- - - - - - -
- - - - -
- -
-
-
- - ) - }} - - -
+
+
+
+ + +
+ +
+
+
+
+ ) + }} +
+
diff --git a/packages/ui/src/components/sticky-accordion-header.css b/packages/ui/src/components/sticky-accordion-header.css index bee8ea78f..d24c5eba6 100644 --- a/packages/ui/src/components/sticky-accordion-header.css +++ b/packages/ui/src/components/sticky-accordion-header.css @@ -1,18 +1,14 @@ [data-component="sticky-accordion-header"] { + --sticky-accordion-top: 0px; position: sticky; - top: 0px; + top: var(--sticky-accordion-top); +} + +[data-slot="accordion-item"]:first-child [data-component="sticky-accordion-header"] { + background-color: var(--background-base); } [data-component="sticky-accordion-header"][data-expanded], [data-slot="accordion-item"][data-expanded] [data-component="sticky-accordion-header"] { z-index: 10; } - -[data-component="sticky-accordion-header"][data-expanded]::before, -[data-slot="accordion-item"][data-expanded] [data-component="sticky-accordion-header"]::before { - content: ""; - z-index: -10; - position: absolute; - inset: 0; - background-color: var(--background-stronger); -}