Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion packages/desktop-electron/src/main/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { homedir, userInfo } from "node:os"
import { dirname } from "node:path"
import type { ReportProblemInput, ReportProblemResult } from "@opencode-ai/app/desktop-api"
import {
Expand Down Expand Up @@ -126,6 +127,26 @@ function fallbackDiagnostics(): ProblemReportDiagnostics {
}
}

// Exact local identifiers no regex can infer (home directory, OS username) — redacted verbatim
// from the report. Best-effort: userInfo() can throw on some platforms, so a failure just
// contributes no extra term rather than blocking the report.
function localRedactTerms(): string[] {
const terms: string[] = []
try {
const home = homedir()
if (home) terms.push(home)
} catch {
// ignore — no home term
}
try {
const name = userInfo().username
if (name) terms.push(name)
} catch {
// ignore — no username term
}
return terms
}

function recentKeyErrors(logTail: string) {
return logTail
.split(/\r?\n/)
Expand Down Expand Up @@ -187,6 +208,10 @@ export function createFeedbackHandler(deps: FeedbackDeps) {

const id = defaultReportId()
const generatedAt = new Date().toISOString()
// Compute the exact runtime terms (home dir, OS username) once and share them across BOTH the
// full report and the clipboard summary — the summary is the same outbound channel, so it must
// scrub the same bare identifiers no regex can infer.
const redactTerms = localRedactTerms()
let diagnostics: ProblemReportDiagnostics
let logTail = ""
let sessionExport: SessionExport = { status: "none" }
Expand Down Expand Up @@ -224,7 +249,7 @@ export function createFeedbackHandler(deps: FeedbackDeps) {
try {
const report = buildProblemReport(
{ diagnostics, logTail, sessionExport, rendererDiagnostics, rendererError: input.rendererError },
{ reportId: id, generatedAt, maxBytes: DEFAULT_PROBLEM_REPORT_MAX_BYTES },
{ reportId: id, generatedAt, maxBytes: DEFAULT_PROBLEM_REPORT_MAX_BYTES, redactTerms },
)
savedReport = await deps.saveReport({ reportId: id, generatedAt, markdown: report.markdown })
} catch (error) {
Expand All @@ -243,6 +268,7 @@ export function createFeedbackHandler(deps: FeedbackDeps) {
recentErrors: recentKeyErrors(logTail),
rendererDiagnostics,
rendererError: input.rendererError,
redactTerms,
})

await deps.copy(summary)
Expand Down
Loading
Loading