Move to a terminal driven integration to have better interactions

This commit is contained in:
2026-08-11 17:10:26 -03:00
parent 89d1a06204
commit b05c28cff0
26 changed files with 679 additions and 4058 deletions
+18 -2
View File
@@ -10,6 +10,20 @@
const { log, oneLine } = require("./util.js");
/** "3m ago", "2h ago", "yesterday", "4d ago", or a date for anything older. */
function relativeTime(date) {
const seconds = Math.max(0, (Date.now() - date.getTime()) / 1000);
if (seconds < 90) return "just now";
const minutes = Math.round(seconds / 60);
if (minutes < 60) return `${minutes}m ago`;
const hours = Math.round(minutes / 60);
if (hours < 24) return `${hours}h ago`;
const days = Math.round(hours / 24);
if (days === 1) return "yesterday";
if (days < 14) return `${days}d ago`;
return date.toLocaleDateString();
}
function projectSlug(path) {
return String(path).replace(/[/.]/g, "-");
}
@@ -68,7 +82,7 @@ function firstPrompt(filePath) {
* Recent sessions for a workspace, newest first.
* Returns [{ id, path, modifiedAt, label }].
*/
function recentSessions(workspacePath, limit = 15) {
function recentSessions(workspacePath, limit = 25) {
const directory = projectDirectory(workspacePath);
if (!directory) return [];
@@ -102,9 +116,11 @@ function recentSessions(workspacePath, limit = 15) {
const recent = sessions.slice(0, limit);
for (const session of recent) {
session.label = firstPrompt(session.path) || session.id.slice(0, 8);
session.relative = relativeTime(session.modifiedAt);
session.shortId = session.id.slice(0, 8);
}
return recent;
}
module.exports = { recentSessions, projectDirectory, projectSlug };
module.exports = { recentSessions, projectDirectory, projectSlug, relativeTime };