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

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

fix(shared): inverted terminal ranges emit no fake lines (#27843)

samkelly880 committed Nov 2, 2026 at 10:49 UTC d7171d30a4e0d51b308326a8b7adb25f4c7277f4
2 files changed +12 -1
packages/shared/src/composerContextReferences.test.ts
+10
@@ -221,6 +221,16 @@ describe("provider projection", () => {
221 expect(project("a\n")).toContain("3 | a\n4 | \n</context>");
222 });
223
224 + it("emits no terminal lines when the captured range is inverted", () => {
225 + const projected = projectComposerContextForProvider({
226 + text: "[log](t3-context://v1/terminal/ctx_t)",
227 + records: [{ ...terminal, lineStart: 10, lineEnd: 5, text: "a\nb\nc\nd\ne\nf" }],
228 + });
229 + expect(projected).toContain('<context kind="terminal" id="ctx_t">');
230 + expect(projected).toContain("terminal: Terminal 1\n</context>");
231 + expect(projected).not.toContain(" | ");
232 + });
233 +
234 it("emits every marker in place and each payload once, escaped, in first-reference order", () => {
235 const text = [
236 "Look at ![shot.png](t3-context://v1/image/ctx_i) and [T1](t3-context://v1/terminal/ctx_t).",
packages/shared/src/composerContextReferences.ts
+2 -1
@@ -253,9 +253,10 @@ function formatComposerContextProviderPayload(record: KnownComposerContextRecord
253 `attachmentId: ${record.attachmentId}`,
254 ].join("\n");
255 case "terminal": {
256 + const lineCount = Math.max(0, record.lineEnd - record.lineStart + 1);
257 const lines = record.text
258 .split("\n")
258 - .slice(0, record.lineEnd - record.lineStart + 1)
259 + .slice(0, lineCount)
260 .map((line, index) => `${record.lineStart + index} | ${line}`);
261 return [`terminal: ${record.terminalLabel}`, ...lines].join("\n");
262 }