Skip to content

The agent that grows with you

Merge pull request #71741 from NousResearch/bb/tui-dim-fallback

brooklyn!2ea1ea0894b0
diff --cc ui-tui/src/__tests__/markdown.test.ts
index 386a0e138ee,214fd5e7ca0..9c4f0eaed6d
--- a/ui-tui/src/__tests__/markdown.test.ts
+++ b/ui-tui/src/__tests__/markdown.test.ts
@@@ -1,35 -1,14 +1,36 @@@
import { PassThrough } from 'stream'
import { Box, renderSync } from '@hermes/ink'
+ import chalk from 'chalk'
import React from 'react'
-import { describe, expect, it } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import { AUDIO_DIRECTIVE_RE, INLINE_RE, Md, MEDIA_LINE_RE, stripInlineMarkup } from '../components/markdown.js'
+import { __resetLinkTitleCache, fetchLinkTitle } from '../lib/externalLink.js'
import { stripAnsi } from '../lib/text.js'
- import { DEFAULT_THEME } from '../theme.js'
+ import { DEFAULT_THEME, LIGHT_THEME } from '../theme.js'
+afterEach(() => {
+ __resetLinkTitleCache()
+ vi.unstubAllGlobals()
+})
+
+// Stub the network and warm the shared title cache, so a subsequent render
+// has the resolved title available synchronously.
+const stubFetchedTitle = (url: string, title: string) => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn().mockResolvedValue(
+ new Response(`<html><head><title>${title}</title></head></html>`, {
+ headers: { 'content-type': 'text/html' },
+ status: 200
+ })
+ )
+ )
+
+ return fetchLinkTitle(url)
+}
+
const matches = (text: string) => [...text.matchAll(INLINE_RE)].map(m => m[0])
const BEL = String.fromCharCode(7)
const ESC = String.fromCharCode(27)