Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-intelligent-assistant': minor
---

Add DOM text extraction for deep context awareness — extracts structured page content (headings, tables, alerts, text) and sends as context alongside user messages
2 changes: 2 additions & 0 deletions workspaces/intelligent-assistant/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ intelligent-assistant:
# auth: dcr
# - name: test-mcp-server
# token: ${MCP_TOKEN_1}
screen-context:
enabled: true
notebooks:
enabled: ${NOTEBOOKS_ENABLED:-false}
queryDefaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ export interface Config {
*/
enabled?: boolean;
};
/**
* DOM text extraction configuration
* @visibility frontend
*/
'dom-extraction'?: {
/**
* Enable/disable DOM text extraction within Screen Context.
* When enabled, extracts structured page content (headings, tables, alerts, text)
* and sends it as context alongside the user's message.
* @default true
* @visibility frontend
*/
enabled?: boolean;
/**
* Maximum characters to extract from the page.
* Higher values provide richer context but consume more LLM tokens.
* @default 8000
* @visibility frontend
*/
maxChars?: number;
};
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import { useTranslation } from '../hooks/useTranslation';
import { useWelcomePrompts } from '../hooks/useWelcomePrompts';
import { ConversationSummary, NotebookSession } from '../types';
import { getAttachments } from '../utils/attachment-utils';
import { extractPageContext } from '../utils/dom-extractor';
import {
ChatbotFootnoteWithIcon,
getCategorizeMessages,
Expand Down Expand Up @@ -660,6 +661,19 @@ export const LightspeedChat = ({
const notebooksEnabled =
configApi.getOptionalBoolean('intelligent-assistant.notebooks.enabled') ??
false;
const screenContextEnabled =
configApi.getOptionalBoolean(
'intelligent-assistant.screen-context.enabled',
) ?? false;
const domExtractionEnabled =
configApi.getOptionalBoolean(
'intelligent-assistant.screen-context.dom-extraction.enabled',
) ?? true;
const domExtractionMaxChars =
configApi.getOptionalNumber(
'intelligent-assistant.screen-context.dom-extraction.maxChars',
) ?? 8000;

const notebooksRouteMatch = useMatch(`${LIGHTSPEED_PATH}/notebooks`);
const notebookViewRouteMatch = useMatch(
`${LIGHTSPEED_PATH}/notebooks/:notebookId`,
Expand Down Expand Up @@ -1136,7 +1150,22 @@ export const LightspeedChat = ({
prompt: message.toString(),
}),
);
handleInputPrompt(message.toString(), getAttachments(fileContents));
const allAttachments = getAttachments(fileContents);

if (screenContextEnabled && domExtractionEnabled) {
const domContext = extractPageContext({
maxChars: domExtractionMaxChars,
});
if (domContext) {
allAttachments.push({
attachment_type: 'configuration',
content_type: 'text/plain',
content: domContext,
});
}
}

handleInputPrompt(message.toString(), allAttachments);
setIsSendButtonDisabled(true);
setFileContents([]);
setDraftMessage('');
Expand Down
Loading
Loading