Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ import {
} from "../lib/attachmentUploadQueue";
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
import { RightPanelSheet } from "./RightPanelSheet";
import { createGitHistoryPanelStore } from "./git-history/GitHistoryPanelState";
import { previewEnvironment } from "../state/preview";
import { clampFileAttachmentUploadBytes } from "@t3tools/client-runtime/state/attachments";
import { appAtomRegistry } from "../rpc/atomRegistry";
Expand Down Expand Up @@ -544,6 +545,7 @@ import {
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
recallableComposerPrompt,
} from "./chat/composerPromptHistory";
import { hasGitHistoryCapability } from "../gitHistoryCapability";

const EMPTY_ACTIVITIES: OrchestrationThreadActivity[] = [];
const EMPTY_QUEUED_MESSAGES: QueuedComposerMessage[] = [];
Expand Down Expand Up @@ -632,6 +634,7 @@ const selectAutoShowFloatingPreview = (settings: { browserAutoShowFloatingPrevie
const DevicePanel = lazy(() =>
import("./device/DevicePanel").then((module) => ({ default: module.DevicePanel })),
);
const GitHistoryPanel = lazy(() => import("./GitHistoryPanel"));
const FilePreviewPanel = lazy(() => import("./files/FilePreviewPanel"));
const EMPTY_PENDING_FILE_SURFACE_IDS: ReadonlySet<string> = new Set();
const TYPE_TO_FOCUS_EDITABLE_SELECTOR = [
Expand Down Expand Up @@ -1760,6 +1763,7 @@ export default function ChatView(props: ChatViewProps) {
const [pendingUserInputQuestionIndexByRequestId, setPendingUserInputQuestionIndexByRequestId] =
useState<Record<string, number>>({});
const shouldUseRightPanelSheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
const [gitHistoryPanelStore] = useState(createGitHistoryPanelStore);
const isMobileViewport = useMediaQuery("max-sm");
const [terminalFocusRequestId, setTerminalFocusRequestId] = useState(0);
const [pullRequestDialogState, setPullRequestDialogState] =
Expand Down Expand Up @@ -2629,6 +2633,7 @@ export default function ChatView(props: ChatViewProps) {
const issuesCapabilityKnown = serverConfig !== null;
const supportsPullRequests = serverConfig?.environment.capabilities.pullRequests === true;
const supportsIssues = serverConfig?.environment.capabilities.issues === true;
const supportsGitHistory = hasGitHistoryCapability(serverConfig?.environment.capabilities);
const issuesSurfaceCapabilityState = resolveSourceControlSurfaceCapability({
capabilityKnown: issuesCapabilityKnown,
supported: supportsIssues,
Expand Down Expand Up @@ -4586,6 +4591,10 @@ export default function ChatView(props: ChatViewProps) {
useRightPanelStore.getState().open(activeThreadRef, "diff");
onDiffPanelOpen?.();
}, [activeThreadRef, isGitRepo, isServerThread, onDiffPanelOpen]);
const addGitHistorySurface = useCallback(() => {
if (!activeThreadRef || !isGitRepo || !supportsGitHistory) return;
useRightPanelStore.getState().open(activeThreadRef, "git-history");
}, [activeThreadRef, isGitRepo, supportsGitHistory]);
const addFilesSurface = useCallback(() => {
if (!activeThreadRef || !activeProject) return;
useRightPanelStore.getState().open(activeThreadRef, "files");
Expand Down Expand Up @@ -9741,6 +9750,19 @@ export default function ChatView(props: ChatViewProps) {
workspaceMutationId={workspaceMutationId}
/>
</Suspense>
) : renderedRightPanelSurface?.kind === "git-history" &&
supportsGitHistory &&
isGitRepo &&
gitCwd !== null ? (
<Suspense fallback={null}>
<GitHistoryPanel
environmentId={environmentId}
cwd={gitCwd}
active={rightPanelOpen}
stateStore={gitHistoryPanelStore}
stateScopeKey={`${activeThreadRef.environmentId}:${activeThreadRef.threadId}`}
/>
</Suspense>
) : renderedRightPanelSurface?.kind === "pull-request" && !pullRequestsCapabilityKnown ? (
<DetailGhost label="Loading pull request" />
) : renderedRightPanelSurface?.kind === "pull-request" && !supportsPullRequests ? (
Expand Down Expand Up @@ -10506,6 +10528,7 @@ export default function ChatView(props: ChatViewProps) {
onAddBrowserInProfile={createBrowserSurface}
onAddTerminal={addTerminalSurface}
onAddDiff={addDiffSurface}
onAddGitHistory={addGitHistorySurface}
onAddFiles={addFilesSurface}
onAddPullRequest={addPullRequestSurface}
onAddIssue={addIssueSurface}
Expand All @@ -10515,6 +10538,7 @@ export default function ChatView(props: ChatViewProps) {
browserAvailable={isPreviewSupportedInRuntime()}
terminalAvailable={activeProject !== null}
diffAvailable={isServerThread && isGitRepo}
gitHistoryAvailable={isGitRepo && supportsGitHistory}
filesAvailable={activeProject !== null}
pullRequestAvailable={pullRequestSurfaceAvailable}
issueAvailable={issueSurfaceAvailable}
Expand Down Expand Up @@ -10567,6 +10591,7 @@ export default function ChatView(props: ChatViewProps) {
onAddBrowserInProfile={createBrowserSurface}
onAddTerminal={addTerminalSurface}
onAddDiff={addDiffSurface}
onAddGitHistory={addGitHistorySurface}
onAddFiles={addFilesSurface}
onAddPullRequest={addPullRequestSurface}
onAddIssue={addIssueSurface}
Expand All @@ -10576,6 +10601,7 @@ export default function ChatView(props: ChatViewProps) {
browserAvailable={isPreviewSupportedInRuntime()}
terminalAvailable={activeProject !== null}
diffAvailable={isServerThread && isGitRepo}
gitHistoryAvailable={isGitRepo && supportsGitHistory}
filesAvailable={activeProject !== null}
pullRequestAvailable={pullRequestSurfaceAvailable}
issueAvailable={issueSurfaceAvailable}
Expand Down
Loading
Loading