@devries-cameron20 / t3code Mirror · read-only / commits / a03e630705
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 13:15 UTC

fix(web): find in thread opens from the thread title menu, so phones can reach it (#22352)

Co-authored-by: maria-rcks <maria@kuuro.net>

Mantas Kantautas committed Oct 29, 2026 at 19:48 UTC a03e630705bc874dc8d0c297a741af3cf7e3a99f
6 files changed +45 -2
apps/web/src/components/ChatView.tsx
+6
@@ -2636,6 +2636,11 @@ export default function ChatView(props: ChatViewProps) {
2636 : EMPTY_PROVIDER_SKILLS;
2637 const threadFindEnabled = isServerThread && serverConfig?.threadFind === true;
2638 const isThreadFindActive = useThreadFindOpen(activeThreadRef, threadFindEnabled);
2639 + const openThreadFindStable = useStableCallback((threadRef: ScopedThreadRef) => {
2640 + if (threadFindEnabled && scopedThreadKey(threadRef) === activeThreadKey) {
2641 + openThreadFind(activeThreadKey);
2642 + }
2643 + });
2644
2645 useChatShortcuts({
2646 enabled: activeThreadId !== null && !backgroundThread,
@@ -3241,6 +3246,7 @@ export default function ChatView(props: ChatViewProps) {
3246 {...(activeDraftLogicalProjectKey
3247 ? { onOpenProjectSettings: handleOpenDraftProjectSettingsStable }
3248 : {})}
3249 + {...(threadFindEnabled ? { onFindInThread: openThreadFindStable } : {})}
3250 />
3251 </header>
3252
apps/web/src/components/chat/ChatHeader.tsx
+4
@@ -1,6 +1,7 @@
1 import {
2 AuthOrchestrationOperateScope,
3 type EnvironmentId,
4 + type ScopedThreadRef,
5 type ThreadId,
6 } from "@t3tools/contracts";
7 import { scopeThreadRef } from "@t3tools/client-runtime/environment";
@@ -54,6 +55,7 @@ interface ChatHeaderProps {
55 rightPanelOpen: boolean;
56 onNewThreadInProject: () => void;
57 onOpenProjectSettings?: (() => void) | undefined;
58 + onFindInThread?: ((threadRef: ScopedThreadRef) => void) | undefined;
59 }
60
61 function resolveRenameCommit(input: {
@@ -80,6 +82,7 @@ export const ChatHeader = memo(function ChatHeader({
82 rightPanelOpen,
83 onNewThreadInProject,
84 onOpenProjectSettings,
85 + onFindInThread,
86 }: ChatHeaderProps) {
87 const activeProjectName = activeProject?.isScratch ? "No project" : activeProject?.title;
88 const activeProjectCwd = activeProject?.workspaceRoot ?? null;
@@ -196,6 +199,7 @@ export const ChatHeader = memo(function ChatHeader({
199 threadRef: isServerThread ? activeThreadRef : null,
200 projectCwd: activeProjectCwd,
201 onStartRename: startRename,
202 + onFind: onFindInThread,
203 canShareWithGuest,
204 });
205 const titleButtonRef = useRef<HTMLButtonElement | null>(null);
apps/web/src/components/threadActionMenu.logic.ts
+6
@@ -2,6 +2,7 @@ import type { ContextMenuItem } from "@t3tools/contracts";
2 import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled";
3
4 export type ThreadActionMenuId =
5 + | "find"
6 | "new-thread-on-branch"
7 | "filter-by-project"
8 | "turn-into-project"
@@ -68,6 +69,7 @@ export function buildDraftActionMenuItems(options: {
69
70 export interface ThreadActionMenuState {
71 readonly canOperate: boolean;
72 + readonly canFind?: boolean;
73 readonly branch: string | null;
74 readonly projectFilter: {
75 readonly label: string;
@@ -98,6 +100,7 @@ export interface ThreadActionMenuState {
100 /** Local navigation, read markers, and copying remain available to read-only clients. */
101 export function threadActionRequiresOperate(action: ThreadActionMenuId): boolean {
102 return ![
103 + "find",
104 "new-thread-on-branch",
105 "project-settings",
106 "mark-unread",
@@ -114,6 +117,9 @@ export function buildThreadActionMenuItems(
117 state: ThreadActionMenuState,
118 ): ReadonlyArray<ContextMenuItem<ThreadActionMenuId>> {
119 const items: ReadonlyArray<ContextMenuItem<ThreadActionMenuId>> = [
120 + ...(state.canFind
121 + ? [{ id: "find" as const, label: "Find in thread", icon: "text-search" }]
122 + : []),
123 ...(state.branch
124 ? [
125 {
apps/web/src/contextMenuFallback.ts
+7
@@ -150,6 +150,13 @@ const ICON_PATHS: Record<string, ReadonlyArray<{ tag: string; attrs: Record<stri
150 { tag: "path", attrs: { d: "M3 5a2 2 0 0 0 2 2h3" } },
151 { tag: "path", attrs: { d: "M3 3v13a2 2 0 0 0 2 2h3" } },
152 ],
153 + "text-search": [
154 + { tag: "path", attrs: { d: "M21 5H3" } },
155 + { tag: "path", attrs: { d: "M10 12H3" } },
156 + { tag: "path", attrs: { d: "M10 19H3" } },
157 + { tag: "circle", attrs: { cx: "17", cy: "15", r: "3" } },
158 + { tag: "path", attrs: { d: "m21 19-1.9-1.9" } },
159 + ],
160 trash: [
161 { tag: "path", attrs: { d: "M3 6h18" } },
162 { tag: "path", attrs: { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" } },
apps/web/src/hooks/useThreadActionMenu.test.ts
+16 -1
@@ -149,11 +149,12 @@ const target = {
149 threadId: ThreadId.make("thread"),
150 };
151 const position = { x: 10, y: 20 };
152 -const createMenu = () =>
152 +const createMenu = (options: { readonly onFind?: (threadRef: typeof target) => void } = {}) =>
153 useThreadActionMenu({
154 threadRef: target,
155 projectCwd: "/project",
156 onStartRename: () => recordEffect("rename"),
157 + onFind: options.onFind,
158 canShareWithGuest: false,
159 });
160
@@ -178,4 +179,18 @@ describe("thread menu permissions", () => {
179 expect(state.effects).toEqual([]);
180 },
181 );
182 +
183 + it("offers find only to a header that can open it, without task permission", async () => {
184 + createMenu().openMenu(position);
185 + expect(state.show.mock.calls[0]![0].some((item) => item.id === "find")).toBe(false);
186 + state.show.mockResolvedValue("find");
187 + const onFind = vi.fn(() => recordEffect("find"));
188 + createMenu({ onFind }).openMenu(position);
189 + await state.completed.promise;
190 + const items = state.show.mock.calls[1]![0];
191 + expect(items[0]).toMatchObject({ id: "find", label: "Find in thread" });
192 + expect(items[0]?.disabled).not.toBe(true);
193 + expect(state.effects).toEqual(["find"]);
194 + expect(onFind).toHaveBeenCalledExactlyOnceWith(target);
195 + });
196 });
apps/web/src/hooks/useThreadActionMenu.ts
+6 -1
@@ -61,9 +61,10 @@ export function useThreadActionMenu(input: {
61 readonly threadRef: ScopedThreadRef | null;
62 readonly projectCwd: string | null;
63 readonly onStartRename: () => void;
64 + readonly onFind?: ((threadRef: ScopedThreadRef) => void) | undefined;
65 readonly canShareWithGuest: boolean;
66 }) {
66 - const { threadRef, projectCwd, onStartRename, canShareWithGuest } = input;
67 + const { threadRef, projectCwd, onStartRename, onFind, canShareWithGuest } = input;
68 const router = useRouter();
69 const projects = useProjects();
70 const primaryEnvironmentId = usePrimaryEnvironmentId();
@@ -133,6 +134,7 @@ export function useThreadActionMenu(input: {
134 const snoozePresets = resolveSnoozePresets(now, timestampFormat, threadRef.environmentId);
135 const items = buildThreadActionMenuItems({
136 canOperate: readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope),
137 + canFind: onFind !== undefined,
138 branch: thread.branch ?? null,
139 projectFilter: null,
140 isPinned: thread.pinnedAt != null,
@@ -187,6 +189,9 @@ export function useThreadActionMenu(input: {
189 }
190 };
191 switch (action) {
192 + case "find":
193 + onFind?.(threadRef);
194 + return;
195 case "project-settings": {
196 const project = projects.find(
197 (candidate) =>