feat: add OSC 8 clickable hyperlinks for file paths in export notifications (#1114)
This commit is contained in:
parent
85642bbb6d
commit
3f9085a588
3 changed files with 13 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ import {
|
|||
} from "./metrics.js";
|
||||
import type { UnitMetrics } from "./metrics.js";
|
||||
import { gsdRoot } from "./paths.js";
|
||||
import { formatDuration } from "../shared/mod.js";
|
||||
import { formatDuration, fileLink } from "../shared/mod.js";
|
||||
|
||||
/**
|
||||
* Write an export file directly, without requiring an ExtensionCommandContext.
|
||||
|
|
@ -241,7 +241,7 @@ export async function handleExport(args: string, ctx: ExtensionCommandContext, b
|
|||
};
|
||||
const outPath = join(exportDir, `export-${timestamp}.json`);
|
||||
writeFileSync(outPath, JSON.stringify(report, null, 2) + "\n", "utf-8");
|
||||
ctx.ui.notify(`Exported to ${outPath}`, "success");
|
||||
ctx.ui.notify(`Exported to ${fileLink(outPath)}`, "success");
|
||||
} else {
|
||||
const totals = getProjectTotals(units);
|
||||
const phases = aggregateByPhase(units);
|
||||
|
|
@ -285,6 +285,6 @@ export async function handleExport(args: string, ctx: ExtensionCommandContext, b
|
|||
|
||||
const outPath = join(exportDir, `export-${timestamp}.md`);
|
||||
writeFileSync(outPath, md, "utf-8");
|
||||
ctx.ui.notify(`Exported to ${outPath}`, "success");
|
||||
ctx.ui.notify(`Exported to ${fileLink(outPath)}`, "success");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,15 @@ export function formatDateShort(iso: string): string {
|
|||
} catch { return iso; }
|
||||
}
|
||||
|
||||
// ─── Hyperlinks ──────────────────────────────────────────────────────────────
|
||||
|
||||
/** Wrap text in an OSC 8 hyperlink for terminals that support clickable links. */
|
||||
export function fileLink(filePath: string, displayText?: string): string {
|
||||
const uri = `file://${filePath}`;
|
||||
const label = displayText ?? filePath;
|
||||
return `\x1b]8;;${uri}\x07${label}\x1b]8;;\x07`;
|
||||
}
|
||||
|
||||
// ─── ANSI Stripping ───────────────────────────────────────────────────────────
|
||||
|
||||
/** Strip ANSI escape sequences from a string. */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export {
|
|||
fitColumns,
|
||||
sparkline,
|
||||
normalizeStringArray,
|
||||
fileLink,
|
||||
} from "./format-utils.js";
|
||||
|
||||
export { shortcutDesc } from "./terminal.js";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue