mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
fix(copilot-plus): render usage-cap link as plain text for ErrorBlock
The streaming error path renders the message via ErrorBlock as plain text (whitespace-pre-wrap), so the Markdown link syntax showed literally as `[purchase credits ...](url)`. Switch formatUsageCapError to a plain-text message with a bare URL, which is readable on the streaming path and still auto-links in any Markdown-rendered context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ou7V5v4UYHkzP3csodLLm
This commit is contained in:
parent
9d3349f185
commit
a011344e48
2 changed files with 8 additions and 3 deletions
|
|
@ -25,7 +25,8 @@ describe("formatUsageCapError", () => {
|
|||
const msg = formatUsageCapError(err);
|
||||
expect(msg).toContain("usage cap");
|
||||
expect(msg).toContain("purchase credits");
|
||||
expect(msg).toContain(`(${DASH})`); // markdown link target
|
||||
expect(msg).toContain(DASH); // bare URL (plain text, renders in ErrorBlock)
|
||||
expect(msg).not.toContain("]("); // not Markdown link syntax
|
||||
});
|
||||
|
||||
it("detects a cap error nested under other transport wrappers", () => {
|
||||
|
|
|
|||
|
|
@ -66,8 +66,12 @@ export function formatUsageCapError(error: unknown): string | null {
|
|||
const fields = findCapFields(error);
|
||||
if (!fields) return null;
|
||||
const url = fields.dashboard_url || USAGE_DASHBOARD_URL;
|
||||
// Plain text with a bare URL (no Markdown). The main streaming error path renders
|
||||
// this via ErrorBlock as plain text (whitespace-pre-wrap), so Markdown link syntax
|
||||
// would show literally; a bare URL stays readable there and still auto-links in any
|
||||
// Markdown-rendered context.
|
||||
return (
|
||||
`**You've reached your usage cap.** To keep going beyond your plan's limit, ` +
|
||||
`[purchase credits on your usage dashboard](${url}).`
|
||||
`You've reached your usage cap. To keep going beyond your plan's limit, ` +
|
||||
`purchase credits on your usage dashboard: ${url}`
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue