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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is a fork of T3 Code that integrates a few additional features, including:
- While the agent works, Chat mode shows "Working for" and the time just above the message box, in the sub-thread where you last wrote to it in that run, or else in the main list.
- "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.
- **The work area:** everything right of the thread list is one area of panes, starting as one pane with a Chat tab for the selected thread. Drag a tab onto a pane's tab strip to move it there, onto an edge of a pane's content to split that side, or onto the middle to join that pane. The tab menu also has Split right and Split down, and when there is one pane, a Split right button at the right end of the tab bar splits it and opens a New tab page. Panes split again in either direction. Drag the divider between two panes, or use the arrow keys on it, to resize (double-click resets it); closing a pane's last tab closes the pane. Any pane that holds a message box (a Chat, a reply tab, or a side-thread tab) stays at least 360 px wide. Drag a thread of the same project from the thread list into the area to open its chat as another Chat tab, and clicking a file link in that chat opens that thread's file as a tab beside it; a thread of another project cannot be dropped into the area, though dropping it on a message box still adds it as context. A thread link, chip, or header breadcrumb in a chat opens a same-project thread as a Chat tab beside the chat, while a thread of another project or environment opens on its own page. Subagents and side chats open as side-thread tabs beside the chat, as in upstream T3 Code; a Cmd or Ctrl click, a middle click, or "Open in main view" opens them on their own page. Reply or "N replies" on a message, or a sub-thread in the Replies list, opens that sub-thread as its own tab (next to the list when opened from the Replies list). "Preview: Toggle", picture-in-picture, and a device's Float hide the tab into the floating player and keep the session; toggling again or choosing "Open in panel" brings the tab back. The Diff toggle hides and reopens the Diff tab. Each thread keeps its own layout. The last Chat tab cannot close, and closing the selected thread's Chat hides it until + → Chat brings it back. Files, links, and diffs that open by themselves go beside the chat, never over it. A window 980 px wide or less shows every tab in one strip and keeps the panes for when there is room. The right panel's show, hide, and maximize controls are gone. A press anywhere on a tab switches to it at once.
- 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/BrowserSurfaceSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useLayoutEffect, useRef } from "react";

import { acquireBrowserSurface } from "./browserSurfaceStore";
import { observeResize } from "../lib/observeResize";
import { WORK_AREA_LAYOUT_EVENT } from "../fork/workArea/workAreaView";

export function BrowserSurfaceSlot(props: {
readonly tabId: string;
Expand Down Expand Up @@ -68,10 +69,12 @@ export function BrowserSurfaceSlot(props: {
const stopObserving = observeResize(observed, update);
window.addEventListener("resize", update);
window.addEventListener("scroll", update, true);
window.addEventListener(WORK_AREA_LAYOUT_EVENT, update);
return () => {
stopObserving();
window.removeEventListener("resize", update);
window.removeEventListener("scroll", update, true);
window.removeEventListener(WORK_AREA_LAYOUT_EVENT, update);
if (updateRef.current === update) updateRef.current = null;
lease.release();
};
Expand Down
17 changes: 11 additions & 6 deletions apps/web/src/browser/openFileInPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as Schema from "effect/Schema";
import { AsyncResult } from "effect/reactivity";

import { resolveAssetUrl } from "~/assets/assetUrls";
import { captureOpenOrigin } from "~/fork/workArea/workAreaView";
import { isPreviewAvailableFor, previewRuntimeFor } from "~/browser/previewRuntime";
import {
applyPreviewServerSnapshot,
Expand Down Expand Up @@ -67,6 +68,7 @@ export async function openUrlInPreview<E>(input: {
}): 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);
const fromOrigin = captureOpenOrigin();
const defaults = await resolveBrowserDefaults().catch(
(cause: unknown) => new BrowserSettingsReadError({ cause }),
);
Expand Down Expand Up @@ -107,7 +109,7 @@ export async function openUrlInPreview<E>(input: {
return;
}
applyPreviewServerSnapshot(threadRef, snapshot);
useRightPanelStore.getState().openBrowser(threadRef, snapshot.tabId);
fromOrigin(() => useRightPanelStore.getState().openBrowser(threadRef, snapshot.tabId));
});
}

Expand Down Expand Up @@ -137,6 +139,7 @@ export async function openFileInPreview<AssetError, PreviewError>(input: {
);
}
const hostRef = rightPanelHostRef(input.threadRef);
const fromOrigin = captureOpenOrigin();
const insideWorkspace =
mediaFileReference(input.filePath, input.workspaceRoot).relativePath !== undefined;
const assetResult = await input.createAssetUrl({
Expand All @@ -158,9 +161,11 @@ export async function openFileInPreview<AssetError, PreviewError>(input: {
Cause.die(new Error("The environment returned an invalid asset URL.")),
);
}
return openUrlInPreview({
threadRef: hostRef,
url: assetUrl,
openPreview: input.openPreview,
});
return fromOrigin(() =>
openUrlInPreview({
threadRef: hostRef,
url: assetUrl,
openPreview: input.openPreview,
}),
);
}
6 changes: 5 additions & 1 deletion apps/web/src/browser/useOpenLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
squashAtomCommandFailure,
} from "@t3tools/client-runtime/state/runtime";
import { recordVisitForThread } from "~/browserHistoryStore";
import { captureOpenOrigin } from "~/fork/workArea/workAreaView";
import { readLocalApi } from "~/localApi";
import { previewEnvironment } from "~/state/preview";
import { useAtomCommand } from "~/state/use-atom-command";
Expand Down Expand Up @@ -34,14 +35,17 @@ export function useOpenLink(threadRef: ScopedThreadRef | null | undefined): (
const openPreview = useAtomCommand(previewEnvironment.open, { reportFailure: false });
return async (url, options = {}) => {
const targetThreadRef = options.threadRef ?? threadRef;
const fromOrigin = captureOpenOrigin();
const target = resolveLinkTarget({
url,
event: options.event ?? NO_MODIFIER,
preference: await resolveBrowserLinkTargetPreference(),
canOpenInApp: canOpenLinksInApp(targetThreadRef),
});
if (target === "app" && targetThreadRef) {
const result = await openUrlInPreview({ threadRef: targetThreadRef, url, openPreview });
const result = await fromOrigin(() =>
openUrlInPreview({ threadRef: targetThreadRef, url, openPreview }),
);
if (isAtomCommandInterrupted(result)) return;
if (result._tag === "Success") {
recordVisitForThread(targetThreadRef, url);
Expand Down
54 changes: 33 additions & 21 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ 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 { useRightPanelStore } from "../rightPanelStore";
import { fromChatOrigin, inChatOrigin, useChatFileOpener } from "../fork/workArea/chatFileOpener";
import { useOpenIssueLink } from "../lib/openIssueLink";
import { issueTrackerEnvironment } from "../state/issueTrackers";
import { useEnvironmentQuery } from "../state/query";
Expand Down Expand Up @@ -619,6 +620,7 @@ function useChatMarkdownState({
reportFailure: false,
});
const pullRequestLinking = usePullRequestLinking(threadRef?.environmentId);
const fileOpener = useChatFileOpener(threadRef);
const environmentId = threadRef?.environmentId ?? explicitEnvironmentId ?? null;
const canOperateHost = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope);
const canOperatePreview = useEnvironmentScope(environmentId, AuthPreviewOperateScope);
Expand All @@ -633,6 +635,7 @@ function useChatMarkdownState({
clickedImage?: HTMLImageElement | null,
) => {
const requestId = ++mediaRequestId.current;
const fileTarget = fileOpener?.();
void resolveMarkdownMediaPreview({
source,
resolvedFilePath,
Expand All @@ -643,9 +646,7 @@ function useChatMarkdownState({
httpBaseUrl:
environmentId === null ? undefined : readPreparedConnection(environmentId)?.httpBaseUrl,
createAssetUrl,
onOpenFile: threadRef
? (path) => useRightPanelStore.getState().openFile(threadRef, path)
: undefined,
onOpenFile: fileTarget ? (path) => fileTarget.openFile(path) : undefined,
}).then(
(preview) => {
if (preview && mediaRequestId.current === requestId) {
Expand Down Expand Up @@ -806,7 +807,10 @@ function useChatMarkdownState({
),
);
}
return openUrlInPreview({ threadRef, url, openPreview }).then((result) => {
const opened = fromChatOrigin(fileOpener, () =>
openUrlInPreview({ threadRef, url, openPreview }),
);
return opened.then((result) => {
if (result._tag === "Success") recordVisitForThread(threadRef, url);
else if (!isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
Expand All @@ -823,7 +827,7 @@ function useChatMarkdownState({
return result;
});
};
const openMarkdownFileInPreview = (path: string) => {
const openMarkdownFileInPreview = inChatOrigin(fileOpener, (path: string) => {
const preparedConnection = threadRef ? readPreparedConnection(threadRef.environmentId) : null;
if (!threadRef || !canOperatePreview || preparedConnection === null) {
return Promise.resolve(
Expand All @@ -844,7 +848,7 @@ function useChatMarkdownState({
createAssetUrl,
openPreview,
});
};
});
const findWorkspaceFileMatch = async (fileLinkMeta: MarkdownFileLinkMeta) => {
const workspaceRelativePath = fileLinkMeta.workspaceLookupPath;
if (
Expand Down Expand Up @@ -919,9 +923,9 @@ function useChatMarkdownState({
return findAgentDirectoryMatch(workspaceRelativePath, agentRoots, searchRoot);
};
const openFileInPanel = (fileLinkMeta: MarkdownFileLinkMeta, panelPath: string) => {
if (!threadRef) return;
const openAt = (path: string) =>
useRightPanelStore.getState().openFile(threadRef, path, fileLinkMeta.line);
const fileTarget = fileOpener?.();
if (!threadRef || !fileTarget) return;
const openAt = (path: string) => fileTarget.openFile(path, fileLinkMeta.line);
if (
fileLinkMeta.workspaceLookupPath === null ||
!cwd ||
Expand All @@ -931,13 +935,13 @@ function useChatMarkdownState({
return;
}
// Anything the user opens in this panel meanwhile, such as a file from the picker, wins.
const panelRef = rightPanelHostRef(threadRef);
const panelRef = fileTarget.panel();
const panelKey = scopedThreadKey(panelRef);
const userActionRevision = useRightPanelStore.getState().markUserAction(panelRef);
void (async () => {
const match = await findWorkspaceFileMatch(fileLinkMeta);
if (
scopedThreadKey(rightPanelHostRef(threadRef)) !== panelKey ||
scopedThreadKey(fileTarget.panel()) !== panelKey ||
useRightPanelStore.getState().getUserActionRevision(panelRef) !== userActionRevision
)
return;
Expand Down Expand Up @@ -1083,6 +1087,7 @@ function useChatMarkdownState({
issuesEnabled,
skills,
threadRef,
fileOpener,
updateThreadPullRequestLink,
};
return {
Expand Down Expand Up @@ -1240,6 +1245,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
imageBaseDir,
markdownFileLinkMetaByHref,
threadRef,
fileOpener,
openMarkdownMedia,
openChangeRequestLink,
openIssueLink,
Expand Down Expand Up @@ -1363,7 +1369,8 @@ const CHAT_MARKDOWN_COMPONENTS = {
onClick?.(event);
if (isWhiteboardLink && href) {
event.preventDefault();
showBoardRef(href, threadRef);
if (fileOpener) fileOpener().openBoardRef(href);
else showBoardRef(href, threadRef);
return;
}
if (isSameDocumentLink && href) {
Expand Down Expand Up @@ -1394,8 +1401,12 @@ const CHAT_MARKDOWN_COMPONENTS = {
}
if (
!href ||
openChangeRequestLink(event, href, undefined, environmentId ?? undefined) ||
openIssueLink(event, href, environmentId ?? undefined, issueTrackers)
fromChatOrigin(
fileOpener,
() =>
openChangeRequestLink(event, href, undefined, environmentId ?? undefined) ||
openIssueLink(event, href, environmentId ?? undefined, issueTrackers),
)
) {
return;
}
Expand Down Expand Up @@ -1512,7 +1523,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
originalUrl={href}
target={pullRequestPreviewTarget}
confirmBeforeOpen={confirmBeforeOpen}
onOpenPullRequest={(targetUrl) =>
onOpenPullRequest={inChatOrigin(fileOpener, (targetUrl: string) =>
openChangeRequestLink(
{
metaKey: false,
Expand All @@ -1523,10 +1534,10 @@ const CHAT_MARKDOWN_COMPONENTS = {
targetUrl,
undefined,
environmentId ?? undefined,
)
}
),
)}
// A reference that is not a pull request may still be an issue this app can show.
onOpenFallback={async (url) => {
onOpenFallback={inChatOrigin(fileOpener, async (url: string) => {
const opened = openIssueLink(
{
metaKey: false,
Expand All @@ -1539,7 +1550,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
issueTrackers,
);
if (!opened) await openDeferredMarkdownLink(url);
}}
})}
fallback={
issuePreviewTarget === null ? undefined : (
<IssueLinkPreviewFallback originalUrl={href} target={issuePreviewTarget} />
Expand Down Expand Up @@ -1628,6 +1639,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
sourceControlMediaRepository,
imageBaseDir,
threadRef,
fileOpener,
workspaceMutationId,
renderContextReference,
fileLinkChip,
Expand Down Expand Up @@ -1676,7 +1688,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
threadId: threadRef.threadId,
path: filePath,
},
onOpen: () => useRightPanelStore.getState().openFile(threadRef, filePath),
onOpen: () => fileOpener?.().openFile(filePath),
}
: imageSource._tag === "Direct"
? { src: resolveProtocolRelativeMediaUrl(imageSource.uri) }
Expand Down
Loading
Loading