webui: add TODO item comment functionality similar to diff comments
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s1040817099be5124k
diff --git a/webui/src/web-components/sketch-chat-input.ts b/webui/src/web-components/sketch-chat-input.ts
index 355c9fc..9667155 100644
--- a/webui/src/web-components/sketch-chat-input.ts
+++ b/webui/src/web-components/sketch-chat-input.ts
@@ -126,6 +126,7 @@
constructor() {
super();
this._handleDiffComment = this._handleDiffComment.bind(this);
+ this._handleTodoComment = this._handleTodoComment.bind(this);
this._handleDragOver = this._handleDragOver.bind(this);
this._handleDragEnter = this._handleDragEnter.bind(this);
this._handleDragLeave = this._handleDragLeave.bind(this);
@@ -135,6 +136,7 @@
connectedCallback() {
super.connectedCallback();
window.addEventListener("diff-comment", this._handleDiffComment);
+ window.addEventListener("todo-comment", this._handleTodoComment);
}
// Utility function to handle file uploads (used by both paste and drop handlers)
@@ -271,10 +273,22 @@
requestAnimationFrame(() => this.adjustChatSpacing());
}
+ private _handleTodoComment(event: CustomEvent) {
+ const { comment } = event.detail;
+ if (!comment) return;
+
+ if (this.content != "") {
+ this.content += "\n\n";
+ }
+ this.content += comment;
+ requestAnimationFrame(() => this.adjustChatSpacing());
+ }
+
// See https://lit.dev/docs/components/lifecycle/
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener("diff-comment", this._handleDiffComment);
+ window.removeEventListener("todo-comment", this._handleTodoComment);
// Clean up drag and drop event listeners
const container = this.renderRoot.querySelector(".chat-container");