From a32fba63ec711418b904be489d9ad87aeae0f6e6 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Fri, 3 Jul 2026 18:29:03 +0300 Subject: [PATCH] feat(comment): db columns for comment suggestions (#315 phase 1) Add suggested_text / suggestion_applied_at / suggestion_applied_by_id to the comments table (migration) and mirror them in the hand-curated db.d.ts Comments interface. suggested_text holds a proposed replacement for the comment's anchored selection; the applied_* columns record who applied it and when. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../20260703T190000-comment-suggestions.ts | 26 +++++++++++++++++++ apps/server/src/database/types/db.d.ts | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts diff --git a/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts b/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts new file mode 100644 index 00000000..2f0523f8 --- /dev/null +++ b/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts @@ -0,0 +1,26 @@ +import { type Kysely } from 'kysely'; + +export async function up(db: Kysely): Promise { + // Agent comment suggestions (#315): a comment may carry a proposed replacement + // for its anchored `selection`, which a human applies via the comment UI. + await db.schema + .alterTable('comments') + // The proposed replacement text (plain text). NULL for ordinary comments. + .addColumn('suggested_text', 'text') + // When the suggestion was applied (NULL until applied). + .addColumn('suggestion_applied_at', 'timestamptz') + // Who applied it (NULL until applied). + .addColumn('suggestion_applied_by_id', 'uuid', (col) => + col.references('users.id').onDelete('set null'), + ) + .execute(); +} + +export async function down(db: Kysely): Promise { + await db.schema + .alterTable('comments') + .dropColumn('suggested_text') + .dropColumn('suggestion_applied_at') + .dropColumn('suggestion_applied_by_id') + .execute(); +} diff --git a/apps/server/src/database/types/db.d.ts b/apps/server/src/database/types/db.d.ts index f4b868cc..dab98b3d 100644 --- a/apps/server/src/database/types/db.d.ts +++ b/apps/server/src/database/types/db.d.ts @@ -173,6 +173,9 @@ export interface Comments { resolvedSource: string | null; selection: string | null; spaceId: string; + suggestedText: string | null; + suggestionAppliedAt: Timestamp | null; + suggestionAppliedById: string | null; type: string | null; updatedAt: Generated; workspaceId: string;