From ab646927ed6a56deb78da2c10f41f73303243318 Mon Sep 17 00:00:00 2001 From: Naeem Dosh Date: Tue, 8 Sep 2026 23:40:43 +0500 Subject: [PATCH] SMB Phase 2: suppress broken preview for SMB docs, copy logical path Frontend overlay (folds into the white-label apply step). Documents synced from SMB shares (source=ingestion_api) have no browsable file, so Onyx's preview click was a dead end. openDocument now, for ingestion_api docs, copies the logical network path (semantic_identifier, e.g. \\company\share\file) to the clipboard with a toast instead of attempting a broken preview. Single change at the shared click chokepoint, so it covers the document sidebar + citations. - branding/smb/smb-ui.patch: the utils.ts change (applies clean to v4.5.2 and on top of the i18n patch; order-independent). - apply-branding.mjs: new step 0b applies it (gated by smbUi.enabled, idempotent via a marker), before the codemod. - branding.config.json: smbUi block. Verified: full apply green (i18n + SMB + branding), idempotent re-apply, no conflict markers. Compile build in progress. Co-Authored-By: Claude Opus 4.8 --- branding/apply-branding.mjs | 33 +++++++++++++++++++++++++++++++++ branding/branding.config.json | 6 ++++++ branding/smb/smb-ui.patch | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 branding/smb/smb-ui.patch diff --git a/branding/apply-branding.mjs b/branding/apply-branding.mjs index dd8a156..a90825c 100644 --- a/branding/apply-branding.mjs +++ b/branding/apply-branding.mjs @@ -124,6 +124,39 @@ if (CONFIG.i18n && CONFIG.i18n.enabled) { } } +// ── 0b. SMB document UI (Phase 2 of the SMB connector) ─────────────────────── +// SMB-synced documents (source=ingestion_api) have no browsable file, so Onyx's +// preview click is a dead end. This patch makes clicking such a cited document +// copy its logical network path instead. Applied before the codemod; idempotent +// via a marker. No-op unless smbUi.enabled. +if (CONFIG.smbUi && CONFIG.smbUi.enabled) { + step("0b SMB document UI overlay"); + const smbPatch = path.join(ROOT, CONFIG.smbUi.patch); + if (!existsSync(smbPatch)) { + warn(`SMB UI patch not found at ${smbPatch} — skipping`); + } else { + const utils = path.join(SRC, "lib/search/utils.ts"); + const marker = "AIDO: documents synced from SMB"; + const already = existsSync(utils) && (await readFile(utils, "utf8")).includes(marker); + if (already) { + ok("SMB UI overlay already applied — skipping"); + } else { + try { + execFileSync("git", ["apply", "-p1", "--check", smbPatch], { cwd: ROOT, stdio: "pipe" }); + } catch { + console.error(`${c.red}✗ SMB UI patch does not apply to the current checkout. It targets web/src/lib/search/utils.ts at ${CONFIG.i18n?.baseCommit || "the pinned release"}; re-sync it or set smbUi.enabled=false.${c.reset}`); + process.exit(1); + } + if (!DRY) { + execFileSync("git", ["apply", "-p1", smbPatch], { cwd: ROOT, stdio: "pipe" }); + ok("applied SMB UI overlay — SMB docs copy their network path instead of a broken preview"); + } else { + ok("SMB UI overlay applies cleanly (dry-run, not written)"); + } + } + } +} + // ── 1. Assets: fetch brand images, repoint favicon ────────────────────────── step("1/4 Assets"); if (!DRY) await mkdir(PUBLIC_BRANDING, { recursive: true }); diff --git a/branding/branding.config.json b/branding/branding.config.json index c1bc5d0..57baf0c 100644 --- a/branding/branding.config.json +++ b/branding/branding.config.json @@ -27,6 +27,12 @@ "dictionaries": "branding/i18n/locales", "$dictionaries_comment": "Client-editable source dictionaries. After the patch is applied, apply-branding.mjs copies dictionaries/.json over web/public/locales//common.json — so edits here PERSIST across `make setup` (they're the source of truth, not the patch). Edit branding/i18n/locales/de.json to add/refine German (see MISSING-de.md for untranslated keys), then `make apply && make build`." }, + "smbUi": { + "$comment": "Phase 2 of the SMB connector (smb-connector/): a tiny frontend overlay so documents synced from SMB/network shares (source=ingestion_api) don't present a broken, dead file-preview. Clicking a cited SMB document copies its logical network path (\\\\company\\share\\...) to the clipboard instead, so the user can open it on the share. Applied on top of the i18n patch, before the branding codemod. Independent of the connector itself; set enabled=false to drop it.", + "enabled": true, + "patch": "branding/smb/smb-ui.patch" + }, + "build": { "$comment": "As of 2026-07, Onyx's web Dockerfile bases on Docker Hardened Images (dhi.io/node:*), a paid Docker offering that requires a DHI subscription + `docker login dhi.io` — so `make build` fails with a registry login error for anyone without DHI access. The apply step rewrites those FROM lines to the equivalent PUBLIC Docker Hub node images (Debian 13 / glibc, matching the DHI variant the Dockerfile targets), so the branded image builds with no login. Keys = the dhi.io image ref (the trailing @sha256 digest, if any, is stripped automatically); values = the public replacement. No-op (with a warning) if the DHI lines are absent, so this stays safe across upstream changes.", "baseImageReplacements": { diff --git a/branding/smb/smb-ui.patch b/branding/smb/smb-ui.patch new file mode 100644 index 0000000..e58ba6f --- /dev/null +++ b/branding/smb/smb-ui.patch @@ -0,0 +1,33 @@ +diff --git a/web/src/lib/search/utils.ts b/web/src/lib/search/utils.ts +index bdb98931..14aa85eb 100644 +--- a/web/src/lib/search/utils.ts ++++ b/web/src/lib/search/utils.ts +@@ -6,6 +6,7 @@ import { + SourceMetadata, + } from "./interfaces"; + import { DateRangePickerValue } from "@/components/dateRangeSelectors/AdminDateRangeSelector"; ++import { toast } from "@opal/layouts"; + + export const buildFilters = ( + sources: SourceMetadata[], +@@ -32,6 +33,20 @@ export const openDocument = ( + document: OnyxDocument, + updatePresentingDocument?: (document: MinimalOnyxDocument) => void + ) => { ++ // AIDO: documents synced from SMB/network shares (ingestion API) have no ++ // browsable link and no stored file to preview — a normal preview click would ++ // just fail. Instead, surface the logical path by copying it to the clipboard ++ // so the user can open the file directly on the share. ++ if (document.source_type === ValidSources.IngestionApi) { ++ const path = document.semantic_identifier || document.document_id; ++ if (path) { ++ void navigator.clipboard ++ ?.writeText(path) ++ .then(() => toast.success(path)) ++ .catch(() => undefined); ++ } ++ return; ++ } + if (document.link) { + window.open(document.link, "_blank"); + } else if (