A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Open the feedback issue in the system browser on the Desktop
Fei2411f0593d1ebdaa
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 9b5e894a..28008d9c 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -10358,6 +10358,21 @@ function entrySummary(entry) {return entry.text;}var SOURCES = { turn: "Model call", host: "DS Bot", api: "DS Bot", browser: "This window" };+function issueWindow() {+ if (window.dshDesktop !== void 0) return { go: (url) => {+ window.open(url, "_blank");+ return true;+ } };+ const reserved = window.open("", "_blank");+ if (reserved !== null) reserved.opener = null;+ return {+ go: (url) => {+ if (reserved === null) return false;+ reserved.location.href = url;+ return true;+ }+ };+}function FeedbackPage({ actions, run, Section, Row: Row3 }) {const [what, setWhat] = (0, import_react27.useState)("");const [report, setReport] = (0, import_react27.useState)(null);@@ -10378,13 +10393,11 @@ function FeedbackPage({ actions, run, Section, Row: Row3 }) {}));const [issueLink, setIssueLink] = (0, import_react27.useState)(null);const openIssue = () => {- const win = window.open("", "_blank");- if (win !== null) win.opener = null;+ const target = issueWindow();run(fetchReport().then(async (next) => {const copied = await copy(next.markdown);const { url, inline } = issueUrl(next.issuesUrl, { what, diagnostics: next.markdown });- if (win !== null) {- win.location.href = url;+ if (target.go(url)) {setIssueLink(null);setNote(inline ? t("Opened a new GitHub issue with the diagnostics filled in. Check it before you submit.") : copied ? t("Opened a new GitHub issue. The diagnostics are long, so they are on the clipboard: paste them into the issue.") : t("Opened a new GitHub issue. Copy the diagnostics below into it."));} else {diff --git a/ds-bot/src/client/feedback.js b/ds-bot/src/client/feedback.jsindex 874e8ff9..69e2cfdd 100644--- a/ds-bot/src/client/feedback.js+++ b/ds-bot/src/client/feedback.js@@ -39,6 +39,24 @@ function entrySummary(entry) {const SOURCES = { turn: 'Model call', host: 'DS Bot', api: 'DS Bot', browser: 'This window' }+// Where the new issue opens; `go(url)` tells whether it did. In a browser the window is+// reserved inside the click gesture and addressed once the diagnostics are gathered:+// opening after the awaits would hit the popup blocker. The Desktop makes no window. It+// hands an http(s) address to the system browser, has no blocker, and returns null even+// then, so it gets the address itself.+function issueWindow() {+ if (window.dshDesktop !== undefined) return { go: (url) => { window.open(url, '_blank'); return true } }+ const reserved = window.open('', '_blank')+ if (reserved !== null) reserved.opener = null+ return {+ go: (url) => {+ if (reserved === null) return false+ reserved.location.href = url+ return true+ },+ }+}+export function FeedbackPage({ actions, run, Section, Row }) {const [what, setWhat] = useState('')const [report, setReport] = useState(null)@@ -56,15 +74,11 @@ export function FeedbackPage({ actions, run, Section, Row }) {}))const [issueLink, setIssueLink] = useState(null)const openIssue = () => {- // The window is reserved inside the click gesture and addressed once the- // diagnostics are gathered; opening after the awaits would hit the blocker.- const win = window.open('', '_blank')- if (win !== null) win.opener = null+ const target = issueWindow()run(fetchReport().then(async (next) => {const copied = await copy(next.markdown)const { url, inline } = issueUrl(next.issuesUrl, { what, diagnostics: next.markdown })- if (win !== null) {- win.location.href = url+ if (target.go(url)) {setIssueLink(null)setNote(inline? t('Opened a new GitHub issue with the diagnostics filled in. Check it before you submit.')diff --git a/ds-bot/test/feedback.test.js b/ds-bot/test/feedback.test.jsnew file mode 100644index 00000000..27ef06c4--- /dev/null+++ b/ds-bot/test/feedback.test.js@@ -0,0 +1,78 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { fileURLToPath } from 'node:url'+import { runInNewContext } from 'node:vm'+import { build } from 'esbuild'++const bundle = await build({+ entryPoints: [fileURLToPath(new URL('../src/client/feedback.js', import.meta.url))],+ bundle: true, format: 'cjs', platform: 'node', write: false,+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],+})+const ISSUES = 'https://github.com/Fei2411/DeepSeek-Bot/issues/new'++// Settings → Feedback in a window whose `open` is `open`, with every state change kept.+function page(window) {+ const notes = []+ const react = {+ createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),+ Fragment: 'fragment',+ useState: initial => [initial, (next) => { if (typeof next === 'string') notes.push(next) }],+ useEffect: () => {},+ useRef: current => ({ current }),+ useLayoutEffect: () => {},+ }+ const module = { exports: {} }+ runInNewContext(bundle.outputFiles[0].text, {+ module, exports: module.exports, window, URL, URLSearchParams, setTimeout, clearTimeout,+ navigator: { clipboard: { writeText: () => Promise.resolve() } },+ require: (name) => {+ if (name === 'react') return react+ if (name === 'react-dom' || name === '@deepseek-ai/dsh-client-ui-primitives') return {}+ throw new Error(`no platform module ${name}`)+ },+ })+ const actions = { diagnostics: async () => ({ markdown: '| DS Bot | 0.1.6 |', issuesUrl: ISSUES, entries: [], total: 0 }) }+ let pending+ const run = (promise) => { pending = promise; return promise }+ const tree = module.exports.FeedbackPage({ actions, run, Section: 'section', Row: 'row' })+ const find = node => (Array.isArray(node) ? node.flatMap(find) : node && typeof node === 'object' ? [...(node.props?.className === 'bt-fb-primary' ? [node] : []), ...find(node.children)] : [])+ return {+ notes,+ report: async () => {+ find(tree)[0].props.onClick()+ await pending+ },+ }+}++// 公开#182: the Desktop hands only an http(s) address to the system browser and returns+// null for every window.open. The blank window reserved for the issue got nothing, and+// the page said the browser blocked the new window.+test('on the Desktop, "Report on GitHub" hands the issue address to the system browser', async () => {+ const opened = []+ const window = { dshDesktop: { protocolVersion: 1 }, open: (url = '') => { opened.push(String(url)); return null } }+ const { notes, report } = page(window)+ await report()+ assert.equal(opened.length, 1)+ assert.ok(opened[0].startsWith(`${ISSUES}?template=bug.yml`))+ assert.equal(notes.some(note => /blocked the new window/.test(note)), false)+ assert.ok(notes.includes('Opened a new GitHub issue with the diagnostics filled in. Check it before you submit.'))+})++test('in a browser, the window reserved in the click gets the issue address', async () => {+ const reserved = { location: { href: '' } }+ const window = { open: () => reserved }+ const { notes, report } = page(window)+ await report()+ assert.equal(reserved.opener, null)+ assert.ok(reserved.location.href.startsWith(`${ISSUES}?template=bug.yml`))+ assert.ok(notes.includes('Opened a new GitHub issue with the diagnostics filled in. Check it before you submit.'))+})++test('in a browser that blocks the window, the page offers the link instead', async () => {+ const { notes, report } = page({ open: () => null })+ await report()+ assert.ok(notes.includes('The browser blocked the new window.'))+ assert.ok(notes.some(note => note.startsWith(`${ISSUES}?template=bug.yml`)))+})