aido-onyx/branding/smb/smb-ui.patch
Naeem Dosh ab646927ed 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>
2026-09-08 23:40:43 +05:00

33 lines
1.3 KiB
Diff

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 (