-
Notifications
You must be signed in to change notification settings - Fork 16
feat: vendor shared file tree + resizable picker from monorepo #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,539
−653
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f02bf49
feat(web): vendor shared file tree + resizable picker from monorepo
dastratakos 63b3f16
Vendor explicit file-focus navigation + viewed/collapse shortcuts (#64)
dastratakos 0c53688
refactor(web): guard --content-top parse to match hosted getContentTop
dastratakos b7a36b4
chore(web): drop stray comment on --content-top parse
dastratakos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,11 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { z } from "zod"; | ||
| import { FilesPage } from "@/routes/files-page"; | ||
|
|
||
| const filesSearchSchema = z.object({ | ||
| scrollTo: z.string().optional(), | ||
| }); | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId/files")({ | ||
| validateSearch: (search) => filesSearchSchema.parse(search), | ||
| component: FilesRoute, | ||
| }); | ||
|
|
||
| function FilesRoute() { | ||
| const { runId } = Route.useParams(); | ||
| const { scrollTo } = Route.useSearch(); | ||
| return <FilesPage runId={runId} scrollTo={scrollTo} />; | ||
| return <FilesPage runId={runId} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 36 additions & 26 deletions
62
packages/web/src/components/chapter/chapter-file-list.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,55 @@ | ||
| import { | ||
| FILE_VIEWED_STATE, | ||
| type FileViewedState, | ||
| FileViewRow, | ||
| } from "@/components/chapter/file-view-row"; | ||
| import type { FileDiffEntry } from "@/lib/parse-diff"; | ||
| import { useMemo, useState } from "react"; | ||
| import { FileFilterInput } from "@/components/files/file-filter-input"; | ||
| import { FileTree, type ViewedConfig } from "@/components/files/file-tree"; | ||
| import { FILE_VIEWED_STATE, type PullRequestFile } from "@/lib/diff-types"; | ||
|
|
||
| // The CLI has no review comments, so the tree never renders comment badges. | ||
| const NO_COMMENT_COUNTS: Map<string, number> = new Map(); | ||
|
|
||
| interface ChapterFileListProps { | ||
| entries: FileDiffEntry[]; | ||
| files: PullRequestFile[]; | ||
| focusedFilePath?: string; | ||
| viewedPathSet: ReadonlySet<string>; | ||
| onToggleFileViewed: (filePath: string) => void; | ||
| onSelectFile: (filePath: string) => void; | ||
| } | ||
|
|
||
| export function ChapterFileList({ | ||
| entries, | ||
| files, | ||
| focusedFilePath, | ||
| viewedPathSet, | ||
| onToggleFileViewed, | ||
| onSelectFile, | ||
| }: ChapterFileListProps) { | ||
| const [filter, setFilter] = useState(""); | ||
|
|
||
| const viewed = useMemo<ViewedConfig>( | ||
| () => ({ | ||
| stateByPath: new Map( | ||
| files.map((file) => [ | ||
| file.path, | ||
| viewedPathSet.has(file.path) ? FILE_VIEWED_STATE.VIEWED : FILE_VIEWED_STATE.UNVIEWED, | ||
| ]), | ||
| ), | ||
| onToggle: onToggleFileViewed, | ||
| }), | ||
| [files, viewedPathSet, onToggleFileViewed], | ||
| ); | ||
|
|
||
| return ( | ||
| <div className="py-3 pl-6 pr-4 lg:pl-8"> | ||
| <h2 className="mb-2 font-medium text-[11px] text-muted-foreground uppercase tracking-wider"> | ||
| Files <span className="text-muted-foreground/60">({entries.length})</span> | ||
| Files <span className="text-muted-foreground/60">({files.length})</span> | ||
| </h2> | ||
| <div className="space-y-0.5"> | ||
| {entries.map(({ file }) => { | ||
| const viewedState: FileViewedState = viewedPathSet.has(file.path) | ||
| ? FILE_VIEWED_STATE.VIEWED | ||
| : FILE_VIEWED_STATE.UNVIEWED; | ||
| return ( | ||
| <FileViewRow | ||
| key={file.path} | ||
| filePath={file.path} | ||
| status={file.status} | ||
| viewedState={viewedState} | ||
| onToggleViewed={onToggleFileViewed} | ||
| onSelect={onSelectFile} | ||
| /> | ||
| ); | ||
| })} | ||
| </div> | ||
| <FileFilterInput value={filter} onChange={setFilter} className="mb-2" /> | ||
| <FileTree | ||
| files={files} | ||
|
dastratakos marked this conversation as resolved.
|
||
| focusedFilePath={focusedFilePath} | ||
| onSelectFile={onSelectFile} | ||
| viewed={viewed} | ||
| commentCountsByPath={NO_COMMENT_COUNTS} | ||
| filter={filter} | ||
| /> | ||
|
dastratakos marked this conversation as resolved.
|
||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/web/src/components/chapter/chapter-panel-constants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /** | ||
| * Shared resize bounds for the chapter side panel. Width is viewport-relative: | ||
| * a 30% default capped at 50%, with a fixed pixel floor. | ||
| */ | ||
| export const CHAPTER_PANEL_MIN_WIDTH = 280; | ||
| export const CHAPTER_PANEL_MAX_WIDTH_FRACTION = 0.5; | ||
|
|
||
| export const resolveChapterPanelDefaultWidth = (viewportWidth: number) => | ||
|
dastratakos marked this conversation as resolved.
|
||
| Math.round(viewportWidth * 0.3); | ||
|
|
||
| export const resolveChapterPanelMaxWidth = (viewportWidth: number) => | ||
| Math.round(viewportWidth * CHAPTER_PANEL_MAX_WIDTH_FRACTION); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.