really fix timestamps

This commit is contained in:
Thomas G. Lopes
2026-03-04 17:05:44 +00:00
parent 0be8ef4c19
commit c7388b45a1
2 changed files with 20 additions and 15 deletions
+18 -13
View File
@@ -62,7 +62,7 @@ export default function (pi: ExtensionAPI) {
return box; return box;
}); });
// Renderer for assistant timestamp // Renderer for legacy timestamp-suffix messages (from old sessions)
pi.registerMessageRenderer("timestamp-suffix", (message, _options, theme) => { pi.registerMessageRenderer("timestamp-suffix", (message, _options, theme) => {
const details = message.details as { timestamp: number; elapsed: string; duration?: number } | undefined; const details = message.details as { timestamp: number; elapsed: string; duration?: number } | undefined;
if (!details) return new Text(""); if (!details) return new Text("");
@@ -104,27 +104,32 @@ export default function (pi: ExtensionAPI) {
if (lastTurnDuration !== null) { if (lastTurnDuration !== null) {
const now = Date.now(); const now = Date.now();
const elapsed = formatElapsed(now - sessionStart); const elapsed = formatElapsed(now - sessionStart);
pi.sendMessage( const timeStr = formatTime(new Date(now));
{ let line = `${timeStr} (+${elapsed})`;
customType: "timestamp-suffix", if (lastTurnDuration > 1000) {
content: "", line += ` • took ${formatDuration(lastTurnDuration)}`;
display: true, }
details: { timestamp: now, elapsed, duration: lastTurnDuration }, ctx.ui.notify(line, "info");
},
{ deliverAs: "followUp", triggerTurn: false }
);
} }
}); });
// Inject timestamp marker right before agent starts // Strip old timestamp-suffix messages from LLM context
pi.on("before_agent_start", async (event) => { pi.on("context", async (event) => {
const messages = event.messages.filter(
(m: any) => m.role !== "custom" || (m.customType !== "timestamp-prefix" && m.customType !== "timestamp-suffix")
);
return { messages };
});
// Inject timestamp marker right before agent starts (inline, persistent)
pi.on("before_agent_start", async () => {
const now = Date.now(); const now = Date.now();
const elapsed = formatElapsed(now - sessionStart); const elapsed = formatElapsed(now - sessionStart);
return { return {
message: { message: {
customType: "timestamp-prefix", customType: "timestamp-prefix",
content: "", content: ".",
display: true, display: true,
details: { timestamp: now, elapsed }, details: { timestamp: now, elapsed },
}, },
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"lastChangelogVersion": "0.55.4", "lastChangelogVersion": "0.55.4",
"defaultProvider": "openrouter", "defaultProvider": "openrouter",
"defaultModel": "openai/gpt-5.2-codex", "defaultModel": "openai/gpt-5.3-codex",
"defaultThinkingLevel": "off", "defaultThinkingLevel": "minimal",
"theme": "matugen", "theme": "matugen",
"lsp": { "lsp": {
"hookMode": "edit_write" "hookMode": "edit_write"