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 <noreply@anthropic.com>
This commit is contained in:
parent
afac2c42ae
commit
ab646927ed
3 changed files with 72 additions and 0 deletions
|
|
@ -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 ──────────────────────────
|
// ── 1. Assets: fetch brand images, repoint favicon ──────────────────────────
|
||||||
step("1/4 Assets");
|
step("1/4 Assets");
|
||||||
if (!DRY) await mkdir(PUBLIC_BRANDING, { recursive: true });
|
if (!DRY) await mkdir(PUBLIC_BRANDING, { recursive: true });
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@
|
||||||
"dictionaries": "branding/i18n/locales",
|
"dictionaries": "branding/i18n/locales",
|
||||||
"$dictionaries_comment": "Client-editable source dictionaries. After the patch is applied, apply-branding.mjs copies dictionaries/<lang>.json over web/public/locales/<lang>/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`."
|
"$dictionaries_comment": "Client-editable source dictionaries. After the patch is applied, apply-branding.mjs copies dictionaries/<lang>.json over web/public/locales/<lang>/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": {
|
"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.",
|
"$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": {
|
"baseImageReplacements": {
|
||||||
|
|
|
||||||
33
branding/smb/smb-ui.patch
Normal file
33
branding/smb/smb-ui.patch
Normal file
|
|
@ -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 (
|
||||||
Loading…
Add table
Reference in a new issue