diff --git a/README.md b/README.md index 69a0acfda1cb1..d30eeeb0e6f8d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This is a fork of T3 Code that integrates a few additional features, including: - **Display mode per thread:** Right-click a thread and set Display mode to "Chat mode" to hide the agent's work and keep the chat simple: you see just your messages and the replies the agent sends to you with its `send_to_user` tool, and the agent answers each message where you wrote it, so a question in the main list gets its answer in the main list. "Normal mode" shows everything again. The mode applies in the web and desktop apps, not in the mobile app. - To follow up on one of the agent's messages without filling the main list, point at it and choose Reply. The replies show in a Replies tab in the right panel (+ → Replies, or the reply line under the message), which has its own reply box, and the agent answers you there. Under a message with replies you see how many it has, how many are new, and a few generated words on what they are about. The agent names the message it answers by its id, with `send_to_user`. A Cite in the main list on a message that already has replies opens those replies and puts the quote in their reply box, unless the main box or the open reply box already has text; then the quote goes there, the main box first. A Cite on any other message goes into the main box. An agent reads the thread as you see it with its `t3_thread_user_view` tool, and to brief another agent in your own words it passes on the result's last line, which shows that agent the same messages and says if they changed since. - In Chat mode the agent sends one reply per message you type, and before a long task it may first send a short "on it" note; a thin line parts two agent messages in a row. To say more, it rewrites its reply in place with its `replace_send_to_user` tool. A rewritten reply shows a small "Edited" mark, and in a sub-thread it counts as new. + - 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. diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 825f54037d12a..3a6a895c1ba0a 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -395,6 +395,11 @@ import { REPLY_BOX_QUEUE_EDIT_BLOCKED, subThreadDraftId } from "../fork/subThrea import { useSubThreadCite } from "../fork/subThreads/subThreadCite"; import { SubThreadViewContext } from "../fork/subThreads/subThreadsState"; import { useThreadShownView } from "../fork/displayMode/threadView"; +import { ChatWorkingIndicator } from "../fork/displayMode/ChatWorkingIndicator"; +import { + scrollToEndBottom, + useChatWorkingReserve, +} from "../fork/displayMode/chatWorkingIndicator.logic"; import { timelineCitation } from "../fork/dashboard/dashboardCitation"; import { useDraftEnvironmentRouting } from "./chat/useDraftEnvironmentRouting"; import { branchMismatchBannerItem, extensionStatusBannerItem } from "./chat/ThreadActivityBanners"; @@ -2187,6 +2192,7 @@ export default function ChatView(props: ChatViewProps) { return result; }; + const chatWorkingReserve = useChatWorkingReserve(isServerThread ? routeThreadDetailRef : null); const { showScrollToBottom, timelineLiveFollowEnabled, @@ -2203,7 +2209,7 @@ export default function ChatView(props: ChatViewProps) { attachComposerOverlay: attachFollowComposerOverlay, } = useTimelineFollow({ legendListRef, - composerTimelineInset, + composerTimelineInset: composerTimelineInset + chatWorkingReserve, routeThreadKey, activeThreadKey, isServerThread, @@ -3638,7 +3644,7 @@ export default function ChatView(props: ChatViewProps) { anchorMessageId={timelineAnchorMessageId} onAnchorReady={onTimelineAnchorReadyStable} onAnchorSizeChanged={onTimelineAnchorSizeChangedStable} - contentInsetEndAdjustment={composerTimelineInset} + contentInsetEndAdjustment={composerTimelineInset + chatWorkingReserve} liveFollowEnabled={timelineLiveFollowEnabled} onIsAtEndChange={onIsAtEndChangeStable} onViewportAttach={attachTimelineViewport} @@ -3654,11 +3660,26 @@ export default function ChatView(props: ChatViewProps) { {showScrollToBottom && !isThreadFindActive && ( scrollToEnd(true)} /> )} + 0} + environmentId={environmentId} + entries={timelineEntries} + working={isWorking} + localSendPending={isSendBusy} + activityRun={activeActivityRun} + runtime={activeRuntime} + startedAt={activeWorkStartedAt} + composerInset={composerTimelineInset} + />
; + readonly working: boolean; + readonly localSendPending: boolean; + readonly activityRun: IndicatorRun | null; + readonly runtime: IndicatorRuntime | null; + readonly startedAt: string | null; + readonly composerInset: number; +}) { + const view = use(SubThreadViewContext); + if ( + !props.chatMode || + !props.working || + !showsWorkingIndicator({ ...props, places: runPlaces(props.entries), view }) + ) + return null; + return ( + + ); +} + +export const WorkingIndicatorLayer = memo(function WorkingIndicatorLayer(props: { + readonly startedAt: string | null; + readonly environmentId: EnvironmentId; + readonly composerInset: number; +}) { + const { startedAt, environmentId } = props; + return ( +
+
+
+ {startedAt === null ? ( + "Working…" + ) : ( + workingForText(startedAt, environmentId, nowMs), + true, + )} + /> + )} +
+
+
+ ); +}); diff --git a/apps/web/src/fork/displayMode/chatWorkingIndicator.browser.test.tsx b/apps/web/src/fork/displayMode/chatWorkingIndicator.browser.test.tsx new file mode 100644 index 0000000000000..73e47b8710b1b --- /dev/null +++ b/apps/web/src/fork/displayMode/chatWorkingIndicator.browser.test.tsx @@ -0,0 +1,69 @@ +import { EnvironmentId } from "@t3tools/contracts"; +import { expect, it } from "vite-plus/test"; +import { page } from "vite-plus/test/browser"; + +import "~/index.css"; + +import { render } from "../../../test/render"; +import { ScrollToEndButton } from "../../components/chat/TimelineOverlays"; +import { scrollToEndBottom, WORKING_INDICATOR_RESERVE_PX } from "./chatWorkingIndicator.logic"; +import { WorkingIndicatorLayer } from "./ChatWorkingIndicator"; + +const environmentId = EnvironmentId.make("working-indicator-layout"); +const COMPOSER_INSET = 120; +const LONG_SUMMARY = + "3 new messages from the agent about the deploy, the lint job and the flaky end-to-end suite"; + +const intersects = (a: DOMRect, b: DOMRect) => + a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom; + +it.each([ + [361, 662], + [1280, 800], +])( + "keeps the working line clear of Scroll to end, aligned with the composer and click-through at %ix%i", + async (width, height) => { + const viewport = { width: window.innerWidth, height: window.innerHeight }; + await page.viewport(width, height); + await using _viewport = { + [Symbol.asyncDispose]: () => page.viewport(viewport.width, viewport.height), + }; + await using screen = await render( +
+