Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is a fork of T3 Code that integrates a few additional features, including:
- "Enable Dashboard", beside Display mode in the same menu, gives the thread a Dashboard in either mode: a Dashboard tab in the right panel (+ → Dashboard) with six status slots that the agent writes with its `dashboard_set` tool and reads with `dashboard_get`. Each slot shows how long ago it changed, and new text stays highlighted until you click the slot. Select text in a slot to quote it with Cite, as you would in a message. Agents can link to the Dashboard in their messages, and a click on the link opens it.
- Settings → Threads → New threads → Display mode picks the mode for threads you start from the message box in the web or desktop app. Threads that agents, scheduled tasks, side chats or the mobile app start open in Normal mode, and existing threads keep their mode.
- **Split the right panel in two:** drag a right-panel tab onto the left or right part of the panel's content and drop it to get two panes side by side, each with its own tabs, as with Windows Snap. Drag tabs between the panes, drag the line between them to resize (double-click resets it), and close or move away a pane's last tab to go back to one pane. The tab menu has Split right, Split left, Move to the other pane and Unsplit. New tabs open in the pane you last used. A narrow window shows all tabs in one strip and keeps the split for when there is room. A press anywhere on a tab now switches to it at once.
- **Drag links into the right panel:** drag a file from the Files tree, or a link from a chat message, onto a right-panel pane to open it there. Supported chat links are file, pull request, issue, thread, `board://`, Dashboard, and web links. Drop the item on a tab strip to open it at that spot. Drop the item on the left or right third of a single pane to split the panel on that side when there is room. If the item is already open in the other pane, the drop moves its tab to where you dropped it. A dropped file keeps a standalone Files tab open beside it. A plain click on a file still replaces the Files tab. A full pull request or issue URL opens as a pull request or issue tab when a click opens that kind of tab. Other web links, and pull request or issue links that do not, drag whenever the preview browser is available. Dropping one opens it in the preview browser, even when a plain click opens it in your system browser. Without a preview browser, those links do not drag to the panel. Folder rows in the Files tree, short references like `#42`, commit links, and web image and video URLs do not drag to the panel. A chat file link drags whenever a click opens it in the panel. A dropped file link opens what its click opens, in the pane you chose. It can open a workspace folder or a workspace image or video file. Dragging a Files row to a message box still adds an `@mention`. In the desktop app on Mac and Windows, file links in chat still drag out as files instead of dropping on the panel.
- Copy buttons on pages in the preview browser now put the copied text into your own clipboard.
- **Two preview browser modes:** Settings → Browser → Preview browser picks the browser the server runs for preview tabs. **T3 native** (fast) is the default. It runs chrome-headless-shell, Chrome's small build that runs without a window. **Chrome** (slow) runs full Chrome, for pages that don't work in T3 native. On platforms where T3 has no Chrome for Testing build (Google's Chrome build for test automation), both choices run T3 native. Switching closes the open preview tabs.
- **Compact when idle for Claude threads:** a choice in Settings → Providers → Advanced → Compact idle threads. Besides compacting before the prompt cache expires, it compacts a large idle Claude thread (default 400K tokens or more) a set time (default 15 minutes) after the last message or answer from a user or a bot, so the compaction runs while no one waits for a reply. The token counts and the wait are set right under the choice.
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/browser/openFileInPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export async function openUrlInPreview<E>(input: {
readonly openPreview: OpenPreviewMutation<E>;
readonly profileId?: PreviewOpenInput["profileId"];
readonly background?: boolean;
/** Runs right after the panel opens the tab, in the same task as that write. */
readonly onOpened?: () => void;
}): Promise<AtomCommandResult<void, E | BrowserSettingsReadError>> {
// Read before any await: a side chat pane that unmounts meanwhile drops its host mapping.
const threadRef = rightPanelHostRef(input.threadRef);
Expand Down Expand Up @@ -108,6 +110,7 @@ export async function openUrlInPreview<E>(input: {
}
applyPreviewServerSnapshot(threadRef, snapshot);
useRightPanelStore.getState().openBrowser(threadRef, snapshot.tabId);
input.onOpened?.();
});
}

Expand Down
46 changes: 34 additions & 12 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ import type {
} from "react-markdown";
import { createIncrementalMarkdownPlugin } from "../markdown-incremental";
import { postWhiteboardHover, remarkWhiteboardLinks } from "../fork/whiteboard/markdown-whiteboard";
import { chatAnchorPanelLinks } from "../fork/rightPanelSplit/chatAnchorLink";
import { openedSync } from "../fork/rightPanelSplit/linkSources";
import { type OpenedSurface, startPanelLinkDrag } from "../fork/rightPanelSplit/panelLinkDrag";
import { showBoardRef } from "../fork/whiteboard/boardChannel";
import { remarkEndLinksAtCjkPunctuation } from "../fork/cjkLinkEnd";
import { DashboardLinkChip, parseDashboardHref } from "../fork/dashboard/dashboardLink";
Expand Down Expand Up @@ -177,7 +180,7 @@ import { appAtomRegistry } from "../rpc/atomRegistry";
import { hostEnvironmentIdAtom } from "../state/primaryEnvironment";
import { cn } from "../lib/utils";
import { resolveRemoteOpenState, useRemoteOpenResolution } from "../remoteOpen";
import { rightPanelHostRef, useRightPanelStore } from "../rightPanelStore";
import { type OpenFileOptions, rightPanelHostRef, useRightPanelStore } from "../rightPanelStore";
import { useOpenIssueLink } from "../lib/openIssueLink";
import { issueTrackerEnvironment } from "../state/issueTrackers";
import { useEnvironmentQuery } from "../state/query";
Expand Down Expand Up @@ -794,7 +797,7 @@ function useChatMarkdownState({
if (!readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope)) return;
await pullRequestLinking.changeLink(threadRef, href, linked);
};
const openExternalLinkInPreview = (url: string) => {
const openExternalLinkInPreview = (url: string, onOpened?: () => void) => {
if (!threadRef || !canOperatePreview) {
return Promise.resolve(
AsyncResult.failure<void, BrowserPreviewUnavailableError>(
Expand All @@ -806,7 +809,8 @@ function useChatMarkdownState({
),
);
}
return openUrlInPreview({ threadRef, url, openPreview }).then((result) => {
const opened = onOpened ? { onOpened } : {};
return openUrlInPreview({ threadRef, url, openPreview, ...opened }).then((result) => {
if (result._tag === "Success") recordVisitForThread(threadRef, url);
else if (!isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
Expand All @@ -823,6 +827,14 @@ function useChatMarkdownState({
return result;
});
};
const anchorPanelLink = chatAnchorPanelLinks({
threadRef,
canOperatePreview,
issueTrackers,
openChangeRequestLink,
openIssueLink,
openExternalLinkInPreview,
});
const openMarkdownFileInPreview = (path: string) => {
const preparedConnection = threadRef ? readPreparedConnection(threadRef.environmentId) : null;
if (!threadRef || !canOperatePreview || preparedConnection === null) {
Expand Down Expand Up @@ -918,30 +930,35 @@ function useChatMarkdownState({
}
return findAgentDirectoryMatch(workspaceRelativePath, agentRoots, searchRoot);
};
const openFileInPanel = (fileLinkMeta: MarkdownFileLinkMeta, panelPath: string) => {
if (!threadRef) return;
const openFileInPanel = (
fileLinkMeta: MarkdownFileLinkMeta,
panelPath: string,
...options: [OpenFileOptions?]
): OpenedSurface | Promise<OpenedSurface> => {
if (!threadRef) return null;
const openAt = (path: string) =>
useRightPanelStore.getState().openFile(threadRef, path, fileLinkMeta.line);
openedSync(rightPanelHostRef(threadRef), () =>
useRightPanelStore.getState().openFile(threadRef, path, fileLinkMeta.line, ...options),
);
if (
fileLinkMeta.workspaceLookupPath === null ||
!cwd ||
workspaceLinkLookupQuery(panelPath, cwd) === null
) {
openAt(panelPath);
return;
return openAt(panelPath);
}
// Anything the user opens in this panel meanwhile, such as a file from the picker, wins.
const panelRef = rightPanelHostRef(threadRef);
const panelKey = scopedThreadKey(panelRef);
const userActionRevision = useRightPanelStore.getState().markUserAction(panelRef);
void (async () => {
return (async () => {
const match = await findWorkspaceFileMatch(fileLinkMeta);
if (
scopedThreadKey(rightPanelHostRef(threadRef)) !== panelKey ||
useRightPanelStore.getState().getUserActionRevision(panelRef) !== userActionRevision
)
return;
openAt(match ?? panelPath);
return null;
return openAt(match ?? panelPath);
})();
};
const fileLinkChip = (
Expand Down Expand Up @@ -1019,7 +1036,7 @@ function useChatMarkdownState({
resolveCopyPaths={async () =>
markdownFileCopyPaths(fileLinkMeta, await resolveHostPath(), cwd)
}
onOpenInPanel={(path) => openFileInPanel(fileLinkMeta, path)}
onOpenInPanel={(path, _line, ...options) => openFileInPanel(fileLinkMeta, path, ...options)}
onOpenMedia={
threadRef && canPreviewMedia
? () => openMarkdownMedia(mediaPath, fileLinkMeta.filePath)
Expand Down Expand Up @@ -1072,6 +1089,7 @@ function useChatMarkdownState({
openIssueLink,
openDeferredMarkdownLink,
openExternalLinkInPreview,
anchorPanelLink,
openMarkdownMedia,
projects,
issueProjects,
Expand Down Expand Up @@ -1246,6 +1264,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
openDeferredMarkdownLink,
linkTargetPreference,
openExternalLinkInPreview,
anchorPanelLink,
projects,
issueProjects,
issueTrackers,
Expand Down Expand Up @@ -1359,6 +1378,9 @@ const CHAT_MARKDOWN_COMPONENTS = {
onMouseLeave={() => {
if (isWhiteboardLink) postWhiteboardHover(null);
}}
onDragStart={(event) =>
startPanelLinkDrag(event, anchorPanelLink(href, pullRequestAutolink))
}
onClick={(event) => {
onClick?.(event);
if (isWhiteboardLink && href) {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function RightPanelTab(
return (
<div
data-active-tab={props.active}
data-right-panel-tab-id={surface.id}
onMouseDown={(event) => {
preventTabMiddleButtonDefault(event);
press.onMouseDown(event);
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/ThreadContextChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ThreadContextRecord, ProjectId } from "@t3tools/contracts";
import { Link, useNavigate } from "@tanstack/react-router";
import { MessagesSquareIcon } from "lucide-react";
import { useGT } from "gt-react";
import type { DragEventHandler } from "react";

import { resolveThreadOpenRoute } from "~/lib/sideChatPane";
import { buildThreadRouteParams } from "~/threadRoutes";
Expand All @@ -18,6 +19,8 @@ export function ThreadContextChip(props: {
projectId?: ProjectId | null;
copyMarkdown?: string;
unreadable?: boolean;
/** Makes the chip draggable; without it the router link does not drag. */
onDragStart?: DragEventHandler<HTMLElement> | undefined;
}) {
const gt = useGT();
const { environmentId, threadId } = props.record;
Expand Down Expand Up @@ -58,7 +61,8 @@ export function ThreadContextChip(props: {
),
});
}}
draggable={false}
draggable={props.onDragStart !== undefined}
onDragStart={props.onDragStart}
/>
}
aria-label={gt("Thread, {title}", { title })}
Expand Down
22 changes: 20 additions & 2 deletions apps/web/src/components/chat/MarkdownFileLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import {
leavesFileChipClickToBrowser,
runHostFileLinkMenuItem,
} from "../../fork/hostFileLinks";
import { fileChipPanelLink } from "../../fork/rightPanelSplit/linkSources";
import { type OpenedSurface, startPanelLinkDrag } from "../../fork/rightPanelSplit/panelLinkDrag";
import { readLocalApi } from "../../localApi";
import { cn } from "../../lib/utils";
import { shouldOpenMarkdownFileLinkInEditor } from "../../markdown-links";
import type { OpenFileOptions } from "../../rightPanelStore";
import type { markdownFileCopyPaths } from "../../markdownFileHostPath";
import { documentChipKindForFileName } from "../../pierre-icons";
import { ContextChip } from "../ContextChip";
Expand Down Expand Up @@ -49,7 +52,12 @@ interface MarkdownFileLinkProps {
theme: "light" | "dark";
threadRef?: ScopedThreadRef | undefined;
onOpen?: (() => Promise<AtomCommandResult<unknown, unknown>>) | undefined;
onOpenInPanel: (panelPath: string, line: number | undefined) => void;
/** The surface it opened in the panel, or null. */
onOpenInPanel: (
panelPath: string,
line: number | undefined,
options?: OpenFileOptions,
) => OpenedSurface | Promise<OpenedSurface>;
resolveDragPath: () => Promise<string>;
resolveCopyPaths: () => Promise<ReturnType<typeof markdownFileCopyPaths>>;
openInEditorMenuLabel: string;
Expand Down Expand Up @@ -127,7 +135,7 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({

const handleOpenInFilePreview = () => {
if (threadRef && panelPath) {
onOpenInPanel(panelPath, line);
void onOpenInPanel(panelPath, line);
return;
}
if (onOpenMedia) {
Expand Down Expand Up @@ -348,6 +356,16 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({
hasPrimaryAction ? (
<ContextChip
{...nativeDrag}
onDragStart={(event) => {
if (nativeDrag.draggable) nativeDrag.onDragStart(event);
else
startPanelLinkDrag(
event,
fileChipPanelLink(threadRef, panelPath, (path, options) =>
onOpenInPanel(path, line, options),
),
);
}}
kind={chipKind}
dir="ltr"
render={<a href={href} />}
Expand Down
34 changes: 28 additions & 6 deletions apps/web/src/components/chat/MarkdownThreadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import { unknownThreadLinkLabel } from "@t3tools/shared/threadLinksCopy";
import { resolveLinkedThreadOpen } from "@t3tools/client-runtime/linked-thread";

import { threadChipPanelLink } from "../../fork/rightPanelSplit/linkSources";
import { startPanelOnlyDrag } from "../../fork/rightPanelSplit/panelLinkDrag";
import { configuredHostedAppUrl } from "../../hostedPairing";
import { useThreadRefs, useThreadShell } from "../../state/entities";
import { useConnectedEnvironmentIds, useEnvironmentIdentities } from "../../state/environments";
Expand Down Expand Up @@ -87,6 +89,12 @@ export function MarkdownThreadLink(props: {
if (linked && linkedLabel !== undefined) {
const knownTitle = props.label ?? written?.title ?? null;
const title = knownTitle ?? gt("Thread on {label}", { label: linkedLabel });
const linkedTarget = {
viaEnvironmentId: props.environmentId,
...writtenRef,
label: linkedLabel,
title: knownTitle,
};
return (
<Tooltip>
<TooltipTrigger
Expand All @@ -96,16 +104,21 @@ export function MarkdownThreadLink(props: {
render={
<button
type="button"
draggable={panelRef !== null}
onDragStart={(event) =>
startPanelOnlyDrag(
event,
threadChipPanelLink({
threadRef: props.threadRef,
target: { kind: "linked", target: linkedTarget },
}),
)
}
{...trigger(
(intent) =>
openLinkedThreadRead({
panelRef,
target: {
viaEnvironmentId: props.environmentId,
...writtenRef,
label: linkedLabel,
title: knownTitle,
},
target: linkedTarget,
intent,
navigate,
}),
Expand Down Expand Up @@ -138,6 +151,15 @@ export function MarkdownThreadLink(props: {
record={{ ...ref, title }}
projectId={resolved?.metadata.projectId ?? null}
copyMarkdown={formatHostedThreadLink(ref, title, configuredHostedAppUrl())}
onDragStart={
props.threadRef
? (event) =>
startPanelOnlyDrag(
event,
threadChipPanelLink({ threadRef: props.threadRef, target: { kind: "local", ref } }),
)
: undefined
}
/>
);
}
16 changes: 15 additions & 1 deletion apps/web/src/components/files/FileBrowserPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { useStableCallback } from "~/hooks/useStableCallback";
import { useTheme } from "~/hooks/useTheme";
import { useWorkspaceMutationRefresh } from "~/hooks/useWorkspaceMutationRefresh";
import { useFileContextMenu, type FileContextMenuAction } from "~/fileContextMenu";
import { fileRowPanelLink } from "~/fork/rightPanelSplit/linkSources";
import { startPanelLinkDrag, usePanelLinkOwner } from "~/fork/rightPanelSplit/panelLinkDrag";
import { readLocalApi } from "~/localApi";
import { T3_PIERRE_ICONS } from "~/pierre-icons";
import { PIERRE_TREE_UNSAFE_CSS, pierreTreeStyle } from "~/pierre-tree-theme";
Expand Down Expand Up @@ -169,6 +171,7 @@ export default function FileBrowserPanel({
const messages = useMessages();
const { resolvedTheme } = useTheme();
const composerRef = useComposerHandleContext();
const panelLinkOwner = usePanelLinkOwner();
const fileContextMenu = useFileContextMenu(environmentId);
const {
entries: directoryEntries,
Expand Down Expand Up @@ -550,7 +553,18 @@ export default function FileBrowserPanel({
contextMenuPointerRef.current = { x: event.clientX, y: event.clientY, at: event.timeStamp };
}}
// Capture dragstart before the tree selects the row so selection sees the drag flag.
onDragStartCapture={(event) => dragMention.handleDragStart(event.nativeEvent)}
onDragStartCapture={(event) => {
const treePath = dragMention.handleDragStart(event.nativeEvent);
startPanelLinkDrag(
event,
fileRowPanelLink({
owner: panelLinkOwner,
treePath,
isFile: (path) => entryKindsRef.current.get(path) === "file",
panelPath,
}),
);
}}
onDragEnd={() => dragMention.handleDragEnd((path) => model.getItem(path)?.deselect())}
onWheel={stopFollowingReveal}
onPointerDown={stopFollowingReveal}
Expand Down
Loading
Loading