From b77ec81cc61e72950dbccb618d37867035bb0b15 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 20 Apr 2026 12:55:41 -0700 Subject: [PATCH] fix: thread logged_at through message stack; Esc handler and localNow fixes - scripts/messaging.py: add logged_at param to create_message; use provided value or fall back to _now_utc() - dev-api.py: add logged_at: Optional[str] = None to MessageCreateBody - web/src/stores/messaging.ts: remove logged_at from Omit, add as optional intersection so callers can pass it through - web/src/components/MessageLogModal.vue: pass logged_at in handleSubmit payload; move @keydown.esc from backdrop to modal-dialog (which holds focus); compute localNow fresh inside watch so it reflects actual open time --- dev-api.py | 1 + scripts/messaging.py | 7 ++++--- web/src/components/MessageLogModal.vue | 16 ++++++++-------- web/src/stores/messaging.ts | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dev-api.py b/dev-api.py index 06e092e..625d129 100644 --- a/dev-api.py +++ b/dev-api.py @@ -4192,6 +4192,7 @@ class MessageCreateBody(BaseModel): from_addr: Optional[str] = None to_addr: Optional[str] = None template_id: Optional[int] = None + logged_at: Optional[str] = None class TemplateCreateBody(BaseModel): diff --git a/scripts/messaging.py b/scripts/messaging.py index 2d5fb3f..b2a2363 100644 --- a/scripts/messaging.py +++ b/scripts/messaging.py @@ -47,6 +47,7 @@ def create_message( from_addr: Optional[str], to_addr: Optional[str], template_id: Optional[int], + logged_at: Optional[str] = None, ) -> dict: """Insert a new message row and return it as a dict.""" con = _connect(db_path) @@ -55,12 +56,12 @@ def create_message( """ INSERT INTO messages (job_id, job_contact_id, type, direction, subject, body, - from_addr, to_addr, template_id) + from_addr, to_addr, logged_at, template_id) VALUES - (?, ?, ?, ?, ?, ?, ?, ?, ?) + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, (job_id, job_contact_id, type, direction, subject, body, - from_addr, to_addr, template_id), + from_addr, to_addr, logged_at or _now_utc(), template_id), ) con.commit() row = con.execute( diff --git a/web/src/components/MessageLogModal.vue b/web/src/components/MessageLogModal.vue index 71120a3..7b5ecee 100644 --- a/web/src/components/MessageLogModal.vue +++ b/web/src/components/MessageLogModal.vue @@ -5,7 +5,6 @@ v-if="show" class="modal-backdrop" @click.self="emit('close')" - @keydown.esc="emit('close')" >