From 1f2bc3fdf13b2f7b6be23373d54efec309918a25 Mon Sep 17 00:00:00 2001 From: nicejames Date: Sat, 23 May 2026 20:55:43 +0900 Subject: [PATCH 1/3] fix(prompt): tighten Comment scope from soft guide to hard constraint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The block opened with 'Scope: apply the user request to the attached preview target by default. ... Preserve unrelated elements.' That reads as a soft preference, and in practice agents still refactor sibling sub-pages, parent layout, or global CSS when the user only intended the attached element. Replace with a hard scope directive: Hard scope: change ONLY the elements identified below by selector / position / pod members. Do NOT modify sibling sub-pages, parent layout, global CSS, design tokens, or unrelated rules even if you notice issues there — surface those as a follow-up note in your reply instead of editing them. If the user's request cannot be satisfied without touching outside this scope, ask the user before proceeding. For visual marks, inspect the screenshot and modify the marked region first. Applied symmetrically to apps/web/src/comments.ts and apps/daemon/src/server.ts so the web composer and the daemon-side attachment renderer stay in sync. --- apps/daemon/src/server.ts | 2 +- apps/web/src/comments.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/daemon/src/server.ts b/apps/daemon/src/server.ts index 98da40cd3..76bc9a23b 100644 --- a/apps/daemon/src/server.ts +++ b/apps/daemon/src/server.ts @@ -805,7 +805,7 @@ export function renderCommentAttachmentHint(commentAttachments) { '', '', '', - 'Scope: treat each attachment as the default refinement target. For visual marks, inspect the screenshot and modify the marked region first. Preserve unrelated areas.', + "Hard scope: change ONLY the elements identified below by selector / position / pod members. Do NOT modify sibling sub-pages, parent layout, global CSS, design tokens, or unrelated rules even if you notice issues there — surface those as a follow-up note in your reply instead of editing them. If the user's request cannot be satisfied without touching outside this scope, ask the user before proceeding. For visual marks, inspect the screenshot and modify the marked region first.", ]; for (const item of commentAttachments) { const targetKind = diff --git a/apps/web/src/comments.ts b/apps/web/src/comments.ts index f0fbd0050..9c1fe5956 100644 --- a/apps/web/src/comments.ts +++ b/apps/web/src/comments.ts @@ -277,7 +277,7 @@ function renderCommentAttachmentContext(commentAttachments: ChatCommentAttachmen '', '', '', - 'Scope: apply the user request to the attached preview target by default. For visual marks, inspect the screenshot and modify the marked region first. Preserve unrelated elements.', + "Hard scope: change ONLY the elements identified below by selector / position / pod members. Do NOT modify sibling sub-pages, parent layout, global CSS, design tokens, or unrelated rules even if you notice issues there — surface those as a follow-up note in your reply instead of editing them. If the user's request cannot be satisfied without touching outside this scope, ask the user before proceeding. For visual marks, inspect the screenshot and modify the marked region first.", ]; commentAttachments.forEach((item) => { const position = normalizePosition(item.pagePosition); From 689ff3ba59d63eb677fa8d0c73ef0f47cc45276e Mon Sep 17 00:00:00 2001 From: nicejames Date: Sat, 23 May 2026 21:34:54 +0900 Subject: [PATCH 2/3] ci: re-trigger checks (transient checkout-auth flake on previous run) From d7b06792aae44cfaf4c8b01dadefb6fb2390df1f Mon Sep 17 00:00:00 2001 From: nicejames Date: Wed, 27 May 2026 22:46:50 +0900 Subject: [PATCH 3/3] test(comments): assert hard-scope sentence text in web and daemon renderers --- apps/daemon/tests/comment-attachments.test.ts | 6 ++++++ apps/web/tests/comments.test.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/apps/daemon/tests/comment-attachments.test.ts b/apps/daemon/tests/comment-attachments.test.ts index 7a17dcefb..ccfdf1a17 100644 --- a/apps/daemon/tests/comment-attachments.test.ts +++ b/apps/daemon/tests/comment-attachments.test.ts @@ -171,6 +171,12 @@ describe('preview comment agent payload', () => { expect(hint).toContain('file: index.html'); expect(hint).toContain('selector: [data-od-id="hero-title"]'); expect(hint).toContain('comment: Make the headline shorter'); + // The hard-scope sentence IS the behavior change. Assert its key phrases + // so a future edit that softens or drops the directive lights the suite + // red instead of silently re-opening the over-broad edit bug. + expect(hint).toContain('Hard scope: change ONLY'); + expect(hint).toContain('Do NOT modify sibling sub-pages, parent layout, global CSS, design tokens, or unrelated rules'); + expect(hint).toContain('ask the user before proceeding'); }); it('renders pod attachments with grouped member context', () => { diff --git a/apps/web/tests/comments.test.ts b/apps/web/tests/comments.test.ts index a7a77a133..cbbff8760 100644 --- a/apps/web/tests/comments.test.ts +++ b/apps/web/tests/comments.test.ts @@ -242,6 +242,12 @@ describe('preview comment attachment helpers', () => { expect(content).toContain(''); expect(content).toContain('selector: [data-od-id="hero-title"]'); expect(content).toContain('comment: Only shorten this title'); + // The hard-scope sentence IS the behavior change. Assert its key phrases + // so a future edit that softens or drops the directive lights the suite + // red instead of silently re-opening the over-broad edit bug. + expect(content).toContain('Hard scope: change ONLY'); + expect(content).toContain('Do NOT modify sibling sub-pages, parent layout, global CSS, design tokens, or unrelated rules'); + expect(content).toContain('ask the user before proceeding'); }); it('adds hidden comment context only to the current user message sent to API providers', () => {