aido-onyx/branding/smb/smb-ui.patch
Naeem Dosh 8c6c6c4016 SMB connector: per-source index document + filename citation labels
Two client-requested changes:

1. Table of contents per source. On each sync the connector writes one
   index document listing every file on the share, grouped by folder, so
   the assistant is aware of the full document set even when a search
   returns only some files. It re-upserts only when the file set changes,
   is excluded from the orphan-delete reconcile (shares the source prefix
   but is not a file), and is removed if SMB_WRITE_INDEX is turned off.

2. Shorter citation labels. semantic_identifier is now the file name, not
   the full path, so the chat/search citation shows "Angebot.pdf" instead
   of a long truncated Z:\... path. The full network path stays in `link`
   and metadata; the UI overlay copies it to the clipboard on click, in
   both the chat view and the licensed Search view. A DOC_FORMAT_VERSION
   bump re-upserts already-synced files once so existing docs get the new
   label without waiting for a content change.

Verified with a mock-client simulation: 17 checks covering filename
labels, full-path copy, index create/update/delete, reconcile whitelist,
add/remove sync, and the one-time format-version re-upsert.
2026-09-23 18:51:34 +05:00

94 lines
4.4 KiB
Diff

diff --git a/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx
index 0f61ede9..2dcb8e7e 100644
--- a/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx
+++ b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx
@@ -179,7 +179,13 @@ function ConnectorRow({
<TableCell>
<CCPairStatus
ccPairStatus={
- ccPairsIndexingStatus.last_finished_status !== null
+ // AIDO: ingestion-API connectors (e.g. the SMB sync) are never run
+ // through Onyx's classic indexer — documents are pushed via the API —
+ // so last_finished_status stays null and the badge would otherwise be
+ // stuck on "Initial Indexing" even though the docs are indexed. Show
+ // the real connector status for them instead.
+ ccPairsIndexingStatus.last_finished_status !== null ||
+ ccPairsIndexingStatus.source === ValidSources.IngestionApi
? ccPairsIndexingStatus.cc_pair_status
: ccPairsIndexingStatus.last_status == "not_started"
? ConnectorCredentialPairStatus.SCHEDULED
diff --git a/web/src/ee/sections/SearchCard.tsx b/web/src/ee/sections/SearchCard.tsx
index 42fb3bd8..a4b8926f 100644
--- a/web/src/ee/sections/SearchCard.tsx
+++ b/web/src/ee/sections/SearchCard.tsx
@@ -10,6 +10,7 @@ import { ValidSources } from "@/lib/types";
import { MinimalOnyxDocument } from "@/lib/search/interfaces";
import { Section } from "@/layouts/general-layouts";
import { Interactive } from "@opal/core";
+import { toast } from "@opal/layouts";
import Truncated from "@/refresh-components/texts/Truncated";
import { timeAgo } from "@opal/time";
import { useMemo } from "react";
@@ -37,6 +38,25 @@ export default function SearchCard({
document.is_internet || document.source_type === ValidSources.Web;
function handleClick() {
+ // AIDO: documents synced from SMB/network shares (ingestion API) have no
+ // browsable link and no stored file to preview — the preview pane would just
+ // fail. Copy the logical path to the clipboard so the user can open the file
+ // directly on the share. Mirrors openDocument() used by the chat view.
+ if (document.source_type === ValidSources.IngestionApi) {
+ // The full network path is in `link` (file://\\server\share\...); the
+ // semantic_identifier is now just the file name, shown as the label.
+ const path =
+ document.link?.replace(/^file:\/\//, "") ||
+ 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", "noopener,noreferrer");
return;
diff --git a/web/src/lib/search/utils.ts b/web/src/lib/search/utils.ts
index ce7eab36..2431a944 100644
--- a/web/src/lib/search/utils.ts
+++ b/web/src/lib/search/utils.ts
@@ -1,5 +1,6 @@
import { ValidSources } from "@/lib/types";
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/interfaces";
+import { toast } from "@opal/layouts";
// If we have a link, open it in a new tab (including if it's a file)
// If above fails and we have a file, update the presenting document
@@ -7,6 +8,25 @@ 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) {
+ // The full network path is in `link` (file://\\server\share\...); the
+ // semantic_identifier is now just the file name, shown as the label.
+ const path =
+ document.link?.replace(/^file:\/\//, "") ||
+ 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 (