Skip to content

feat: add page-aware Flow chat context - #98

Open
Maurice-aXeTech wants to merge 3 commits into
frappe:developfrom
aXeTech-NL:feature/include-desk-context-upstream
Open

feat: add page-aware Flow chat context#98
Maurice-aXeTech wants to merge 3 commits into
frappe:developfrom
aXeTech-NL:feature/include-desk-context-upstream

Conversation

@Maurice-aXeTech

@Maurice-aXeTech Maurice-aXeTech commented Aug 16, 2026

Copy link
Copy Markdown

Summary

  • add explicit, permission-checked Desk page context to Flow chat turns
  • include current form values (including unsaved edits), visible list rows, generic page text, and minimal direct-link match metadata
  • persist context per Flow Run, revalidate permissions on resume, and keep context out of the system prompt
  • add an Ask Flow page-title action plus explicit context suggestions when navigating between documents
  • add a minimized bottom bar that coexists with Frappe's minimized dialogs
  • require confirmation before durable update_memory writes
  • discover inbound context relations through Frappe's Link-field-only helper, avoiding its broad Dynamic Link scan

Context behavior

Page context is opt-in and one-shot. When a conversation is open and the user navigates to another document, Flow offers to attach that document's context to the next message. It is never sent automatically, and an armed context is cancelled when the active page changes.

Frappe v16 compatibility fix

Frappe's broad get_references_across_doctypes() helper also scans Dynamic Link fields. On Frappe v16.25.0 this can attempt to iterate a None query result from the virtual Permission Inspector DocType and fail document/list context with:

TypeError: 'NoneType' object is not iterable

Flow already excludes Dynamic Links and child-table relation paths. The PR now calls get_references_across_doctypes_by_link_field() directly, so only ordinary Link relationships are discovered. Metadata, permissions, permitted fields, target options, deduplication, and relation limits remain revalidated by Flow.

Security and limits

  • record and field-level read permissions are enforced server-side
  • list rows are read through permission-aware APIs and capped
  • password fields, dynamic links, and child-table relation paths are excluded
  • persisted context is tied to the exact run and revalidated before resume
  • total stored context and model prompt contribution are bounded
  • page data is appended as user-level data rather than system instructions

Validation

  • ruff check and formatting checks pass
  • Python modules compile successfully
  • frontend production build passes with Vite
  • JavaScript syntax checks and git diff --check pass
  • integration coverage added for document/list permissions, context limits, prompt placement, per-run persistence, resume behavior, and memory confirmation
  • relationship regression coverage verifies that the Link-only helper is used and the broad Dynamic Link helper is never called
  • the Link-only path was process-locally verified with Project context and the expected related_project relationships

@greptile-apps

greptile-apps Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "fix: skip dynamic links in page context" | Re-trigger Greptile

Comment thread flow/lib/page_context.py
Comment thread flow/lib/page_context.py Outdated
@Maurice-aXeTech
Maurice-aXeTech marked this pull request as draft August 16, 2026 21:46
@Maurice-aXeTech

Copy link
Copy Markdown
Author

Added a Frappe v16 compatibility fix in c8712c5.

Flow now uses get_references_across_doctypes_by_link_field() for inbound page-context relations instead of the broad helper. This avoids the Dynamic Link scan that can fail on virtual DocTypes such as Permission Inspector (TypeError: 'NoneType' object is not iterable) while preserving ordinary Link relations.

Regression coverage asserts that the Link-only helper is called and the broad helper is not. The updated fork release is tagged v16.1.2 at peeled commit 9b656645f6f5e5d1ff7065cdd086d39ecf95e534.

@Maurice-aXeTech
Maurice-aXeTech marked this pull request as ready for review August 16, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant