forked from pingdotgg/t3code
-
Notifications
You must be signed in to change notification settings - Fork 2
Merge upstream/main into fork (batch 5) #9
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bbab1fc
chore(release): prepare v0.0.10
github-actions[bot] 2ac7356
chore(release): align package versions before building artifacts (#933)
maria-rcks ff6a66d
Use live thread activities for sidebar status pills (#919)
dbalders 8636ea0
Add maria-rcks to the list of contributors
t3dotgg e3d46b6
feat: split out components from ChatView.tsx (#860)
Ymit24 31972e2
Merge upstream/main into fork with ChatView modular split
aaditagrawal cd95414
Fix CodeRabbit review issues from PR #9 round 1
aaditagrawal 5414eda
Fix CodeRabbit review issues from PR #9 round 2
aaditagrawal c98163d
Fix CodeRabbit review issues from PR #9 round 3
aaditagrawal 07c3366
Fix path traversal check to validate segment-level not substring
aaditagrawal 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
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
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
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,136 @@ | ||
| import { type ProviderKind, type ThreadId } from "@t3tools/contracts"; | ||
| import { type ChatMessage, type Thread } from "../types"; | ||
| import { randomUUID } from "~/lib/utils"; | ||
| import { type ComposerImageAttachment, type DraftThreadState } from "../composerDraftStore"; | ||
|
|
||
| export const LAST_INVOKED_SCRIPT_BY_PROJECT_KEY = "t3code:last-invoked-script-by-project"; | ||
| const WORKTREE_BRANCH_PREFIX = "t3code"; | ||
|
|
||
| export function readLastInvokedScriptByProjectFromStorage(): Record<string, string> { | ||
| const stored = localStorage.getItem(LAST_INVOKED_SCRIPT_BY_PROJECT_KEY); | ||
| if (!stored) return {}; | ||
|
|
||
| try { | ||
| const parsed: unknown = JSON.parse(stored); | ||
| if (!parsed || typeof parsed !== "object") return {}; | ||
| return Object.fromEntries( | ||
| Object.entries(parsed).filter( | ||
| (entry): entry is [string, string] => | ||
| typeof entry[0] === "string" && typeof entry[1] === "string", | ||
| ), | ||
| ); | ||
| } catch { | ||
| return {}; | ||
| } | ||
| } | ||
|
|
||
| export function buildLocalDraftThread( | ||
| threadId: ThreadId, | ||
| draftThread: DraftThreadState, | ||
| defaults: { | ||
| readonly provider: ProviderKind; | ||
| readonly model: string; | ||
| }, | ||
| error: string | null, | ||
| ): Thread { | ||
| return { | ||
| id: threadId, | ||
| codexThreadId: null, | ||
| projectId: draftThread.projectId, | ||
| title: "New thread", | ||
| provider: defaults.provider, | ||
| model: defaults.model, | ||
| runtimeMode: draftThread.runtimeMode, | ||
| interactionMode: draftThread.interactionMode, | ||
| session: null, | ||
| messages: [], | ||
| error, | ||
| createdAt: draftThread.createdAt, | ||
| latestTurn: null, | ||
| lastVisitedAt: draftThread.createdAt, | ||
| branch: draftThread.branch, | ||
| worktreePath: draftThread.worktreePath, | ||
| turnDiffSummaries: [], | ||
| activities: [], | ||
| proposedPlans: [], | ||
| }; | ||
| } | ||
|
|
||
| export function revokeBlobPreviewUrl(previewUrl: string | undefined): void { | ||
| if (!previewUrl || typeof URL === "undefined" || !previewUrl.startsWith("blob:")) { | ||
| return; | ||
| } | ||
| URL.revokeObjectURL(previewUrl); | ||
| } | ||
|
|
||
| export function revokeUserMessagePreviewUrls(message: ChatMessage): void { | ||
| if (message.role !== "user" || !message.attachments) { | ||
| return; | ||
| } | ||
| for (const attachment of message.attachments) { | ||
| if (attachment.type !== "image") { | ||
| continue; | ||
| } | ||
| revokeBlobPreviewUrl(attachment.previewUrl); | ||
| } | ||
| } | ||
|
|
||
| export function collectUserMessageBlobPreviewUrls(message: ChatMessage): string[] { | ||
| if (message.role !== "user" || !message.attachments) { | ||
| return []; | ||
| } | ||
| const previewUrls: string[] = []; | ||
| for (const attachment of message.attachments) { | ||
| if (attachment.type !== "image") continue; | ||
| if (!attachment.previewUrl || !attachment.previewUrl.startsWith("blob:")) continue; | ||
| previewUrls.push(attachment.previewUrl); | ||
| } | ||
| return previewUrls; | ||
| } | ||
|
|
||
| export type SendPhase = "idle" | "preparing-worktree" | "sending-turn"; | ||
|
|
||
| export interface PullRequestDialogState { | ||
| initialReference: string | null; | ||
| key: number; | ||
| } | ||
|
|
||
| export function readFileAsDataUrl(file: File): Promise<string> { | ||
| return new Promise((resolve, reject) => { | ||
| const reader = new FileReader(); | ||
| reader.addEventListener("load", () => { | ||
| if (typeof reader.result === "string") { | ||
| resolve(reader.result); | ||
| return; | ||
| } | ||
| reject(new Error("Could not read image data.")); | ||
| }); | ||
| reader.addEventListener("error", () => { | ||
| reject(reader.error ?? new Error("Failed to read image.")); | ||
| }); | ||
| reader.readAsDataURL(file); | ||
| }); | ||
| } | ||
|
|
||
| export function buildTemporaryWorktreeBranchName(): string { | ||
| // Keep the 8-hex suffix shape for backend temporary-branch detection. | ||
| const token = randomUUID().slice(0, 8).toLowerCase(); | ||
| return `${WORKTREE_BRANCH_PREFIX}/${token}`; | ||
| } | ||
|
|
||
| export function cloneComposerImageForRetry( | ||
| image: ComposerImageAttachment, | ||
| ): ComposerImageAttachment { | ||
| if (typeof URL === "undefined" || !image.previewUrl.startsWith("blob:")) { | ||
| return image; | ||
| } | ||
| try { | ||
| return { | ||
| ...image, | ||
| previewUrl: URL.createObjectURL(image.file), | ||
| }; | ||
| } catch { | ||
| return image; | ||
| } | ||
| } | ||
|
|
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.