cue-console 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/package.json +1 -1
- package/src/components/chat-view.tsx +5 -3
- package/src/lib/db.ts +24 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1121,8 +1121,10 @@ export function ChatView({ type, id, name, onBack }: ChatViewProps) {
|
|
|
1121
1121
|
el.style.overflowY = el.scrollHeight > maxPx ? "auto" : "hidden";
|
|
1122
1122
|
}, [input]);
|
|
1123
1123
|
|
|
1124
|
+
const parseDbTime = (dateStr: string) => new Date((dateStr || "").replace(" ", "T"));
|
|
1125
|
+
|
|
1124
1126
|
const formatDivider = (dateStr: string) => {
|
|
1125
|
-
const d =
|
|
1127
|
+
const d = parseDbTime(dateStr);
|
|
1126
1128
|
return d.toLocaleString("zh-CN", {
|
|
1127
1129
|
month: "2-digit",
|
|
1128
1130
|
day: "2-digit",
|
|
@@ -1267,8 +1269,8 @@ export function ChatView({ type, id, name, onBack }: ChatViewProps) {
|
|
|
1267
1269
|
const prevTime = prev?.time;
|
|
1268
1270
|
const showDivider = (() => {
|
|
1269
1271
|
if (!prevTime) return true;
|
|
1270
|
-
const a =
|
|
1271
|
-
const b =
|
|
1272
|
+
const a = parseDbTime(prevTime).getTime();
|
|
1273
|
+
const b = parseDbTime(curTime).getTime();
|
|
1272
1274
|
return b - a > 5 * 60 * 1000;
|
|
1273
1275
|
})();
|
|
1274
1276
|
|
package/src/lib/db.ts
CHANGED
|
@@ -445,6 +445,26 @@ export function getPendingCountByAgent(agentId: string): number {
|
|
|
445
445
|
return result.count;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
function formatLocalIsoWithOffset(d: Date): string {
|
|
449
|
+
const offset = -d.getTimezoneOffset();
|
|
450
|
+
const sign = offset >= 0 ? "+" : "-";
|
|
451
|
+
const pad2 = (n: number) => String(Math.abs(n)).padStart(2, "0");
|
|
452
|
+
const pad3 = (n: number) => String(Math.abs(n)).padStart(3, "0");
|
|
453
|
+
|
|
454
|
+
const year = d.getFullYear();
|
|
455
|
+
const month = pad2(d.getMonth() + 1);
|
|
456
|
+
const day = pad2(d.getDate());
|
|
457
|
+
const hours = pad2(d.getHours());
|
|
458
|
+
const minutes = pad2(d.getMinutes());
|
|
459
|
+
const seconds = pad2(d.getSeconds());
|
|
460
|
+
const ms = pad3(d.getMilliseconds());
|
|
461
|
+
|
|
462
|
+
const offsetHours = pad2(Math.floor(Math.abs(offset) / 60));
|
|
463
|
+
const offsetMinutes = pad2(Math.abs(offset) % 60);
|
|
464
|
+
|
|
465
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${ms}${sign}${offsetHours}:${offsetMinutes}`;
|
|
466
|
+
}
|
|
467
|
+
|
|
448
468
|
export function sendResponse(
|
|
449
469
|
requestId: string,
|
|
450
470
|
response: UserResponse,
|
|
@@ -452,11 +472,13 @@ export function sendResponse(
|
|
|
452
472
|
): void {
|
|
453
473
|
const db = getDb();
|
|
454
474
|
|
|
475
|
+
const createdAt = formatLocalIsoWithOffset(new Date());
|
|
476
|
+
|
|
455
477
|
// Insert response
|
|
456
478
|
db.prepare(
|
|
457
479
|
`INSERT OR IGNORE INTO cue_responses (request_id, response_json, cancelled, created_at)
|
|
458
|
-
VALUES (?, ?, ?,
|
|
459
|
-
).run(requestId, JSON.stringify(response), cancelled ? 1 : 0);
|
|
480
|
+
VALUES (?, ?, ?, ?)`
|
|
481
|
+
).run(requestId, JSON.stringify(response), cancelled ? 1 : 0, createdAt);
|
|
460
482
|
|
|
461
483
|
// Update request status
|
|
462
484
|
db.prepare(
|