mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-07 16:19:09 +00:00
* fix: make plan view mobile friendly (#1636) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit7ee3e05724) * fix: return to thread after plan approval (#1637) Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commitf32e492ab4) * feat: reviews block agenda, sticky headers, accurate diff scroll (#1653) Rework the AI-sorted blocks experience on the PR reviews page into a Google-Docs-style outline: the left sidebar is now a clean number+title agenda with scroll-spy highlighting of the active block; each block shows its title + description (sticky) above its diff; and diff rows are pinned to a uniform height so scroll-to lands precisely via the virtualizer's own geometry instead of an estimate-driven correction loop. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 0b76afdc955e33805c7623d1502a75a9c7c9c1b7) * fix: jump + ResizeObserver settle for review scroll-to (#1655) Replace smooth-scroll plus frame-count correction loops on the PR reviews page with an instant jump that re-asserts its target via a ResizeObserver (the real "layout settled" signal). Block/file navigation and finding/comment centering now land deterministically as off-screen cards mount, files expand, and annotation cards measure, instead of racing a smooth-scroll animation against height reconciliation. Holds bail on user wheel/touch input and after a short ceiling, and a new navigation cancels the previous hold. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Johannes du Plessis <johannes@langchain.dev> (cherry picked from commit 7530653bba7774d66a54b8bef0d2bbc25f519942) * fix: purge expired thread_wakeup crons (#1656) * fix: purge expired thread_wakeup crons One-shot wakeup crons set an end_time that stops re-firing but the cron row is never deleted, so dead rows accumulate (86 in prod). Add a purge that deletes thread_wakeup crons past their end_time, called opportunistically before scheduling a new wakeup, plus a one-time backfill script. Conservative: matches only kind=thread_wakeup with a past end_time. * chore: retrigger Open SWE review --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 9e5a1924ef306269322c31342a1831e57831cfee) * fix: add top padding to sticky review block header (#1660) * fix: add top padding to sticky review block header The sticky per-block header on the reviews page had padding below but none above, so the block number badge sat glued against the top edge when pinned. Add matching top padding for breathing room. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * chore: use py-2 shorthand for review block header padding Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 23bd4a63fc5ba0fe853babf79ed33feb866cc8b2) * fix: use global tokens for sidebar filter popover border (#1661) The filter popover renders via base-ui Menu.Portal into document.body, outside the .agents-ui container where the --ui-* CSS variables are scoped. As a result border-[var(--ui-border)] resolved to an undefined variable and border-color fell back to currentColor, producing a strong near-black border (separators/hover/labels were similarly off). Switch the portaled popup styling to the same global shadcn tokens the theme/settings popover (SidebarUserMenu) already uses (border-border, bg-border, bg-muted, text-muted-foreground). These are defined at :root so they resolve inside portals too, and match the settings popover. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 63eb9a08209f683016abf01cdcc548bc5905f158) * fix: preserve dashboard redirect after login (#1668) * fix: preserve dashboard redirect after login Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * test: cover plan login redirect in e2e Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit bc7ce59169b5350da7286164afb83a7b037b528d) * Disable React StrictMode (#1654) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 6575c327a3ac2b107a6e79a04fa61168d779dbf0) * docs(upstream-sync): add cherry-pick runbook Repo-specific runbook for bringing upstream (langchain-ai/open-swe) commits into the fork: triage-sync discovery, the git cp workflow, the triage ledger, themed-branch layout, and conflict/regression handling. --------- Co-authored-by: Johannes du Plessis <johannes@langchain.dev> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev> Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: Caroline di Vittorio <43390382+carolinedivittorio@users.noreply.github.com>
313 lines
8.3 KiB
TypeScript
313 lines
8.3 KiB
TypeScript
import { memo, useCallback, useEffect, useMemo } from "react"
|
|
import {
|
|
FileTree,
|
|
useFileTree,
|
|
useFileTreeSelection,
|
|
} from "@pierre/trees/react"
|
|
import { ListBulletsIcon, TreeViewIcon } from "@phosphor-icons/react"
|
|
import type { ReactNode } from "react"
|
|
|
|
import type {
|
|
FileTreeDirectoryHandle,
|
|
GitStatus,
|
|
GitStatusEntry,
|
|
} from "@pierre/trees"
|
|
import type { ReviewDiffFile } from "@/lib/api"
|
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
import {
|
|
TREE_UNSAFE_CSS,
|
|
treeThemeStyle,
|
|
} from "@/components/agents/AgentGitPanel"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
function reviewFileGitStatus(status: ReviewDiffFile["status"]): GitStatus {
|
|
if (status === "removed") return "deleted"
|
|
if (status === "added") return "added"
|
|
if (status === "renamed") return "renamed"
|
|
return "modified"
|
|
}
|
|
|
|
export type ReviewSidebarView = "ai" | "files"
|
|
|
|
export interface ReviewSidebarGroup {
|
|
index: number
|
|
title: string
|
|
}
|
|
|
|
export interface ReviewSidebarData {
|
|
title: string
|
|
files: Array<ReviewDiffFile> | null
|
|
selected: string | null
|
|
viewed: Set<string>
|
|
onSelect: (path: string) => void
|
|
groups: Array<ReviewSidebarGroup> | null
|
|
view: ReviewSidebarView
|
|
onViewChange: (view: ReviewSidebarView) => void
|
|
onSelectGroup: (index: number) => void
|
|
// The block currently pinned at the top of the diff (scroll-spy), highlighted
|
|
// in the agenda. null when no block is active or the AI view isn't shown.
|
|
activeGroup: number | null
|
|
}
|
|
|
|
export function ReviewSidebarPanel({ data }: { data: ReviewSidebarData }) {
|
|
const hasGroups = data.groups !== null && data.groups.length > 0
|
|
const showAi = data.view === "ai" && hasGroups
|
|
|
|
return (
|
|
<div className="flex min-h-0 flex-1 flex-col pb-2">
|
|
<div className="flex items-center justify-between gap-2 px-4 py-1">
|
|
<span className="text-[10px] font-medium tracking-wide text-[var(--ui-text-dim)] uppercase">
|
|
{data.title}
|
|
</span>
|
|
{hasGroups && (
|
|
<ReviewViewToggle view={data.view} onChange={data.onViewChange} />
|
|
)}
|
|
</div>
|
|
{showAi ? (
|
|
<ReviewGroupList
|
|
groups={data.groups ?? []}
|
|
activeGroup={data.activeGroup}
|
|
onSelectGroup={data.onSelectGroup}
|
|
/>
|
|
) : !data.files ? (
|
|
<div className="px-4 pt-1">
|
|
<Skeleton className="h-40 w-full" />
|
|
</div>
|
|
) : (
|
|
<ReviewFileTreeExplorer
|
|
files={data.files}
|
|
selected={data.selected}
|
|
onSelect={data.onSelect}
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function ReviewViewToggle({
|
|
view,
|
|
onChange,
|
|
}: {
|
|
view: ReviewSidebarView
|
|
onChange: (view: ReviewSidebarView) => void
|
|
}) {
|
|
return (
|
|
<div className="flex items-center gap-0.5 rounded-md border border-[var(--ui-border)] p-0.5">
|
|
<ReviewViewToggleButton
|
|
active={view === "ai"}
|
|
label="AI sorted"
|
|
onClick={() => onChange("ai")}
|
|
>
|
|
<ListBulletsIcon className="size-3.5" />
|
|
</ReviewViewToggleButton>
|
|
<ReviewViewToggleButton
|
|
active={view === "files"}
|
|
label="File tree"
|
|
onClick={() => onChange("files")}
|
|
>
|
|
<TreeViewIcon className="size-3.5" />
|
|
</ReviewViewToggleButton>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function ReviewViewToggleButton({
|
|
active,
|
|
label,
|
|
onClick,
|
|
children,
|
|
}: {
|
|
active: boolean
|
|
label: string
|
|
onClick: () => void
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onClick}
|
|
aria-label={label}
|
|
aria-pressed={active}
|
|
title={label}
|
|
className={cn(
|
|
"flex size-5 items-center justify-center rounded text-[var(--ui-text-dim)] transition-colors",
|
|
active
|
|
? "bg-[var(--ui-sidebar-hover)] text-[var(--ui-text)]"
|
|
: "hover:text-[var(--ui-text)]"
|
|
)}
|
|
>
|
|
{children}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
function ReviewGroupList({
|
|
groups,
|
|
activeGroup,
|
|
onSelectGroup,
|
|
}: {
|
|
groups: Array<ReviewSidebarGroup>
|
|
activeGroup: number | null
|
|
onSelectGroup: (index: number) => void
|
|
}) {
|
|
return (
|
|
<div className="min-h-0 flex-1 overflow-y-auto py-1">
|
|
{groups.map((group) => (
|
|
<ReviewGroupRow
|
|
key={group.index}
|
|
group={group}
|
|
active={group.index === activeGroup}
|
|
onSelectGroup={onSelectGroup}
|
|
/>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
// Render a title with `backtick`-delimited spans as inline code chips, matching
|
|
// the Markdown component's inline-code styling, without pulling in the full
|
|
// block renderer for a single line.
|
|
export function renderInlineCode(text: string): Array<ReactNode> {
|
|
return text.split(/(`[^`]+`)/g).map((part, i) => {
|
|
if (part.length >= 2 && part.startsWith("`") && part.endsWith("`")) {
|
|
return (
|
|
<code
|
|
key={i}
|
|
className="rounded bg-[var(--ui-panel-2)] px-1 py-0.5 font-mono text-[0.9em] text-[var(--ui-accent)]"
|
|
>
|
|
{part.slice(1, -1)}
|
|
</code>
|
|
)
|
|
}
|
|
return <span key={i}>{part}</span>
|
|
})
|
|
}
|
|
|
|
// A single agenda entry: just the block number + title, like a Google-Docs
|
|
// outline. Clicking (or Enter/Space) scrolls the diff to that block. The active
|
|
// block (scroll-spy) gets an accent rule + emphasis. memo'd so scroll-spy
|
|
// re-renders only repaint the rows whose active state actually changed.
|
|
const ReviewGroupRow = memo(function ReviewGroupRow({
|
|
group,
|
|
active,
|
|
onSelectGroup,
|
|
}: {
|
|
group: ReviewSidebarGroup
|
|
active: boolean
|
|
onSelectGroup: (index: number) => void
|
|
}) {
|
|
const title = useMemo(() => renderInlineCode(group.title), [group.title])
|
|
const selectGroup = useCallback(
|
|
() => onSelectGroup(group.index),
|
|
[onSelectGroup, group.index]
|
|
)
|
|
const onKeyDown = useCallback(
|
|
(event: React.KeyboardEvent) => {
|
|
if (event.key === "Enter" || event.key === " ") {
|
|
event.preventDefault()
|
|
onSelectGroup(group.index)
|
|
}
|
|
},
|
|
[onSelectGroup, group.index]
|
|
)
|
|
|
|
return (
|
|
<div
|
|
role="button"
|
|
tabIndex={0}
|
|
aria-current={active ? "true" : undefined}
|
|
onClick={selectGroup}
|
|
onKeyDown={onKeyDown}
|
|
className={cn(
|
|
"flex cursor-pointer items-start gap-2 border-l-2 px-3 py-1.5 text-left transition-colors",
|
|
active
|
|
? "border-[var(--ui-accent)] bg-[var(--ui-sidebar-hover)]"
|
|
: "border-transparent hover:bg-[var(--ui-sidebar-hover)]"
|
|
)}
|
|
>
|
|
<span className="mt-px shrink-0 text-[11px] font-medium text-[var(--ui-text-dim)] tabular-nums">
|
|
{group.index}.
|
|
</span>
|
|
<span
|
|
className={cn(
|
|
"min-w-0 text-xs leading-5",
|
|
active
|
|
? "font-medium text-[var(--ui-text)]"
|
|
: "text-[var(--ui-text-muted)]"
|
|
)}
|
|
>
|
|
{title}
|
|
</span>
|
|
</div>
|
|
)
|
|
})
|
|
|
|
function ReviewFileTreeExplorer({
|
|
files,
|
|
selected,
|
|
onSelect,
|
|
}: {
|
|
files: Array<ReviewDiffFile>
|
|
selected: string | null
|
|
onSelect: (path: string) => void
|
|
}) {
|
|
const paths = useMemo(() => files.map((file) => file.path), [files])
|
|
const gitStatus = useMemo<Array<GitStatusEntry>>(
|
|
() =>
|
|
files.map((file) => ({
|
|
path: file.path,
|
|
status: reviewFileGitStatus(file.status),
|
|
})),
|
|
[files]
|
|
)
|
|
|
|
const { model } = useFileTree({
|
|
paths,
|
|
gitStatus,
|
|
flattenEmptyDirectories: true,
|
|
density: "default",
|
|
icons: "complete",
|
|
unsafeCSS: TREE_UNSAFE_CSS,
|
|
})
|
|
|
|
useEffect(() => {
|
|
model.resetPaths(paths)
|
|
}, [model, paths])
|
|
|
|
useEffect(() => {
|
|
model.setGitStatus(gitStatus)
|
|
}, [model, gitStatus])
|
|
|
|
const selection = useFileTreeSelection(model)
|
|
useEffect(() => {
|
|
const path = selection[0]
|
|
if (path) onSelect(path)
|
|
}, [selection, onSelect])
|
|
|
|
useEffect(() => {
|
|
if (!selected) return
|
|
const segments = selected.split("/")
|
|
for (let depth = 1; depth < segments.length; depth += 1) {
|
|
const item = model.getItem(segments.slice(0, depth).join("/"))
|
|
if (item?.isDirectory()) (item as FileTreeDirectoryHandle).expand()
|
|
}
|
|
model.scrollToPath(selected, { focus: false })
|
|
}, [model, selected])
|
|
|
|
return (
|
|
<div className="min-h-0 flex-1">
|
|
<FileTree
|
|
model={model}
|
|
style={
|
|
{
|
|
height: "100%",
|
|
...treeThemeStyle(),
|
|
// Must stay opaque: the tree's truncation marker ("…") paints
|
|
// this color behind itself to hide the overflowing filename.
|
|
"--trees-theme-sidebar-bg": "var(--ui-sidebar)",
|
|
} as React.CSSProperties
|
|
}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|