@devries-cameron20 / t3code-1 / commits / 1ea5e4b42d
Fork 0

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

fix(web): typing in the file editor no longer jumps to the prompt (#35122)

Co-authored-by: user <user@qubes-os.org> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Christian R. Kounatze committed Nov 14, 2026 at 20:23 UTC 1ea5e4b42d63965d37ff20cd358271acd6bf2c2a
3 files changed +67 -26
apps/web/src/components/files/FilePreviewPanel.test.ts
+17 -1
@@ -5,7 +5,7 @@ import { ProjectReadFileError } from "@t3tools/contracts";
5 import * as Schema from "effect/Schema";
6 import { describe, expect, it, vi } from "vite-plus/test";
7
8 -import { remapFileCommentAnnotations } from "./fileCommentAnnotations";
8 +import { promptFileCommentEntries, remapFileCommentAnnotations } from "./fileCommentAnnotations";
9 import {
10 filePreviewReadErrorMessage,
11 isMarkdownPreviewFile,
@@ -63,6 +63,22 @@ describe("file comment annotations", () => {
63 },
64 ]);
65 });
66 +
67 + it("shows only drafts and comments still in the prompt", () => {
68 + const entry = (id: string, kind: "draft" | "comment") => ({
69 + id,
70 + kind,
71 + startLine: 3,
72 + endLine: 3,
73 + text: "",
74 + });
75 + expect(
76 + promptFileCommentEntries(
77 + [entry("sent", "comment"), entry("new", "draft"), entry("kept", "comment")],
78 + new Set(["kept"]),
79 + ),
80 + ).toEqual([entry("new", "draft"), entry("kept", "comment")]);
81 + });
82 });
83
84 describe("isMarkdownPreviewFile", () => {
apps/web/src/components/files/FilePreviewPanel.tsx
+42 -25
@@ -76,7 +76,7 @@ import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
76 import { ScrollArea } from "~/components/ui/scroll-area";
77 import { stackedThreadToast, toastManager } from "~/components/ui/toast";
78 import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
79 -import { buildFileReviewComment } from "~/reviewCommentContext";
79 +import { buildFileReviewComment, type ReviewCommentContext } from "~/reviewCommentContext";
80 import { assetEnvironment } from "~/state/assets";
81 import { usePreviewAvailable } from "~/browser/previewRuntime";
82 import { useEnvironmentHttpBaseUrl, usePrimaryEnvironmentId } from "~/state/environments";
@@ -105,6 +105,7 @@ import {
105 nextFileCommentId,
106 normalizeFileCommentRange,
107 remapFileCommentAnnotations,
108 + promptFileCommentEntries,
109 } from "./fileCommentAnnotations";
110 import { installFileEditorDismissal } from "./fileEditorDismissal";
111 import {
@@ -667,6 +668,8 @@ function useFileLineReveal(
668 };
669 }
670
671 +const EMPTY_REVIEW_COMMENTS: ReadonlyArray<ReviewCommentContext> = [];
672 +
673 const createFileEditor: EditorFactory<FileCommentAnnotationGroup, undefined> = (
674 editorType,
675 options,
@@ -760,6 +763,12 @@ function EditableFileSurface({
763 }: EditableFileSurfaceProps) {
764 const addReviewComment = useComposerDraftStore((store) => store.addReviewComment);
765 const removeReviewComment = useComposerDraftStore((store) => store.removeReviewComment);
766 + const promptCommentIds = new Set(
767 + useComposerDraftStore(
768 + (store) =>
769 + store.getComposerDraft(composerDraftTarget)?.reviewComments ?? EMPTY_REVIEW_COMMENTS,
770 + ).map((comment) => comment.id),
771 + );
772 const [lineAnnotations, setLineAnnotations] = useState<FileCommentLineAnnotation[]>([]);
773 const [selectionOverride, setSelectionOverride] = useState<FileSelectionOverride | null>(null);
774 const selectedRange =
@@ -808,7 +817,7 @@ function EditableFileSurface({
817 setLineAnnotations((current) => (current === nextLineAnnotations ? current : remapped));
818 for (const annotation of remapped) {
819 for (const entry of annotation.metadata.entries) {
811 - if (entry.kind !== "comment") continue;
820 + if (entry.kind !== "comment" || !promptCommentIds.has(entry.id)) continue;
821 addReviewComment(
822 composerDraftTarget,
823 buildFileReviewComment({
@@ -974,29 +983,37 @@ function EditableFileSurface({
983 }}
984 selectedLines={selectedRange}
985 lineAnnotations={lineAnnotations}
977 - renderAnnotation={(annotation) => (
978 - <div className="py-1">
979 - {annotation.metadata.entries.map((entry) => (
980 - <DiffCommentAnnotation
981 - key={entry.id}
982 - environmentId={environmentId}
983 - projectId={projectId}
984 - ownerKey={JSON.stringify([
985 - environmentId,
986 - composerDraftTarget,
987 - relativePath,
988 - entry.id,
989 - ])}
990 - kind={entry.kind}
991 - rangeLabel={formatFileCommentRange(entry.startLine, entry.endLine)}
992 - text={entry.text}
993 - onCancel={() => removeAnnotationEntry(entry.id)}
994 - onComment={(text) => submitAnnotationEntry(entry.id, text)}
995 - onDelete={() => removeAnnotationEntry(entry.id)}
996 - />
997 - ))}
998 - </div>
999 - )}
986 + renderAnnotation={(annotation) => {
987 + // Sent comments stay annotated so a failed send can restore them at remapped lines.
988 + const entries = promptFileCommentEntries(
989 + annotation.metadata.entries,
990 + promptCommentIds,
991 + );
992 + if (entries.length === 0) return null;
993 + return (
994 + <div className="py-1">
995 + {entries.map((entry) => (
996 + <DiffCommentAnnotation
997 + key={entry.id}
998 + environmentId={environmentId}
999 + projectId={projectId}
1000 + ownerKey={JSON.stringify([
1001 + environmentId,
1002 + composerDraftTarget,
1003 + relativePath,
1004 + entry.id,
1005 + ])}
1006 + kind={entry.kind}
1007 + rangeLabel={formatFileCommentRange(entry.startLine, entry.endLine)}
1008 + text={entry.text}
1009 + onCancel={() => removeAnnotationEntry(entry.id)}
1010 + onComment={(text) => submitAnnotationEntry(entry.id, text)}
1011 + onDelete={() => removeAnnotationEntry(entry.id)}
1012 + />
1013 + ))}
1014 + </div>
1015 + );
1016 + }}
1017 className="min-h-full"
1018 />
1019 </Virtualizer>
apps/web/src/components/files/fileCommentAnnotations.ts
+8
@@ -52,3 +52,11 @@ export function remapFileCommentAnnotations(
52 },
53 }));
54 }
55 +
56 +/** Drafts and the comments still in the prompt; sent or removed ones are not shown or re-added. */
57 +export function promptFileCommentEntries(
58 + entries: ReadonlyArray<FileCommentAnnotationEntry>,
59 + promptCommentIds: ReadonlySet<string>,
60 +): FileCommentAnnotationEntry[] {
61 + return entries.filter((entry) => entry.kind === "draft" || promptCommentIds.has(entry.id));
62 +}