Skip to content

Feat/see source values (STIT-493)#159

Merged
AlexAxthelm merged 13 commits into
mainfrom
feat/see-source-values
Jul 9, 2026
Merged

Feat/see source values (STIT-493)#159
AlexAxthelm merged 13 commits into
mainfrom
feat/see-source-values

Conversation

@AlexAxthelm

@AlexAxthelm AlexAxthelm commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Add component to expand FieldCards into a detailed view of the component sources in priority fallback order, with winner highlighted.

Adds endpoint to API to provide data for detailed view. Note that the current Resource Detail endpoint won't be sufficient for this after we introduce per-field priorities (upcoming PR).

Also note, the owner/operator fields aren't included in this at this time (more complex behavior)

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

CD summary 7e3a2fb

Frontend: https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-159-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net
stitch-llm open pr-159-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_159 stitch-dev.postgres.database.azure.com 5432 pr_159
Jobs (2)
job image postgres_db api_url auth_mode
db-migrations ghcr.io/rmi/stitch-api:pr-159@sha256:4c6f1206bb3354048b300b7cd402ba0f45017fd586249c70d676e73e2d9fa750 pr_159
seed ghcr.io/rmi/stitch-seed:pr-159@sha256:528b85515404f8c3a33b1afe0609e5d621370400a99564a17f5a10a70ac2e11c https://pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io/api/v1 stitch-client-bearer-token
Images (4)
build_time commit_time git_sha image image_digest
2026-07-03T13:49:42Z 2026-07-03T13:49:28Z 981aa8b ghcr.io/rmi/stitch-api:pr-159 ghcr.io/rmi/stitch-api:pr-159@sha256:4c6f1206bb3354048b300b7cd402ba0f45017fd586249c70d676e73e2d9fa750
2026-07-03T13:49:44Z 2026-07-03T13:49:28Z 981aa8b ghcr.io/rmi/stitch-entity-linkage:pr-159 ghcr.io/rmi/stitch-entity-linkage:pr-159@sha256:aa9261d37c434acd6deccd94b8e20994d66b038e5b012271c470d15203bafd3f
2026-07-03T13:49:46Z 2026-07-03T13:49:28Z 981aa8b ghcr.io/rmi/stitch-seed:pr-159 ghcr.io/rmi/stitch-seed:pr-159@sha256:528b85515404f8c3a33b1afe0609e5d621370400a99564a17f5a10a70ac2e11c
2026-07-03T13:49:45Z 2026-07-03T13:49:28Z 981aa8b ghcr.io/rmi/stitch-stitch-llm:pr-159 ghcr.io/rmi/stitch-stitch-llm:pr-159@sha256:11769ac5d8a4d8d5eef0055cc19dd36533762dc41aca9d865238834f2c8daf82

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

CD summary b1934a1

Frontend: https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-159-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net
stitch-llm open pr-159-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_159 stitch-dev.postgres.database.azure.com 5432 pr_159
Jobs (1)
job image postgres_db
db-migrations ghcr.io/rmi/stitch-api:pr-159@sha256:7c91485e30f635fd4f9b72e15761d41c17681f195afecbf131f673e56bef509d pr_159
Images (4)
build_time commit_time git_sha image image_digest
2026-07-06T10:26:58Z 2026-07-06T10:26:44Z 9e70f3d ghcr.io/rmi/stitch-api:pr-159 ghcr.io/rmi/stitch-api:pr-159@sha256:7c91485e30f635fd4f9b72e15761d41c17681f195afecbf131f673e56bef509d
2026-07-06T10:27:02Z 2026-07-06T10:26:44Z 9e70f3d ghcr.io/rmi/stitch-entity-linkage:pr-159 ghcr.io/rmi/stitch-entity-linkage:pr-159@sha256:8f5f251a038c1674c43c0c799995c723d54dad9418cc4bd184815dbe1c5d03f8
2026-07-06T10:27:02Z 2026-07-06T10:26:44Z 9e70f3d ghcr.io/rmi/stitch-seed:pr-159 ghcr.io/rmi/stitch-seed:pr-159@sha256:913db5d93e9399763c9e3170dc62ee6112aa24f39b671f2f5bd5798c2c423cfc
2026-07-06T10:27:02Z 2026-07-06T10:26:44Z 9e70f3d ghcr.io/rmi/stitch-stitch-llm:pr-159 ghcr.io/rmi/stitch-stitch-llm:pr-159@sha256:574a5fa04e39b00d3cbdad99e83004914f1794c86d28239b6cba40b970e8a0da

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “see source values” capability so users can inspect every source’s value for an individual field (ordered by effective priority), exposed via a new backend endpoint and surfaced in the resource detail UI via an expandable field card.

Changes:

  • Backend: introduce a per-field “source values” response model + DB action + API route (/{id}/fields/{field}/sources) and integration tests.
  • Frontend: add query/hook wiring and a new ResourceFieldCard that lazily fetches and displays all source values when expanded.
  • Seed/test updates: add demo seed data and expand component/page test coverage for the new behavior.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/stitch-ogsi/src/stitch/ogsi/model/init.py Adds OGFieldSourceValueView response model for per-field source values.
deployments/api/src/stitch/api/db/og_field_resource_actions.py Implements field_source_values DB action to compute/sort per-source values with licensing and validation.
deployments/api/src/stitch/api/routers/oil_gas_fields.py Exposes new GET endpoint /{id}/fields/{field}/sources returning OGFieldSourceValueView[].
deployments/api/tests/db/test_resource_actions.py Adds integration tests covering sorting, overrides, omission rules, licensing, and error cases.
deployments/stitch-frontend/src/queries/api.js Adds getFieldSourceValues API client function.
deployments/stitch-frontend/src/queries/resources.js Adds React Query keys + query definition for field source-values.
deployments/stitch-frontend/src/hooks/useResources.js Adds useFieldSourceValues hook (real + mock) wrapping the new query.
deployments/stitch-frontend/src/components/ResourceFieldCard.jsx New UI component that makes a field card expandable to show per-source values on demand.
deployments/stitch-frontend/src/components/ResourceFieldCard.test.jsx Tests expand/collapse, lazy enabling, winner highlighting, and loading/error/empty states.
deployments/stitch-frontend/src/components/FieldCard.jsx Enhances FieldCard to optionally render as an expandable toggle button with panel content.
deployments/stitch-frontend/src/components/FieldCard.test.jsx Adds tests for new expandable button behavior and panel rendering.
deployments/stitch-frontend/src/pages/ResourceDetailPage.jsx Switches key field displays to ResourceFieldCard to enable per-field source inspection.
deployments/stitch-frontend/src/pages/ResourceDetailPage.test.jsx Mocks useFieldSourceValues to keep page tests stable with the new component usage.
deployments/seed/data/006-source-values-demo.json Adds seed/demo data illustrating multi-source values for a resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/stitch-ogsi/src/stitch/ogsi/model/__init__.py
Comment thread deployments/stitch-frontend/src/hooks/useResources.js Outdated
Comment thread deployments/stitch-frontend/src/components/ResourceFieldCard.jsx
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

CD summary f7151b1

Frontend: https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-159-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net
stitch-llm open pr-159-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_159 stitch-dev.postgres.database.azure.com 5432 pr_159
Jobs (1)
job image postgres_db
db-migrations ghcr.io/rmi/stitch-api:pr-159@sha256:64d2d371aeea72220812c6f67802b93580a6b8d20fbe391aa07f288a4fb69c43 pr_159
Images (4)
build_time commit_time git_sha image image_digest
2026-07-06T14:48:17Z 2026-07-06T14:47:58Z 9936ddf ghcr.io/rmi/stitch-api:pr-159 ghcr.io/rmi/stitch-api:pr-159@sha256:64d2d371aeea72220812c6f67802b93580a6b8d20fbe391aa07f288a4fb69c43
2026-07-06T14:48:18Z 2026-07-06T14:47:58Z 9936ddf ghcr.io/rmi/stitch-entity-linkage:pr-159 ghcr.io/rmi/stitch-entity-linkage:pr-159@sha256:babee0705d82325c3cba5817740ee486e7d0e9e1d7aaa42c0763fed3141d6af6
2026-07-06T14:48:17Z 2026-07-06T14:47:58Z 9936ddf ghcr.io/rmi/stitch-seed:pr-159 ghcr.io/rmi/stitch-seed:pr-159@sha256:fa5f02ffd937ebe7cf684f01944e438679182f81e021a45ba34b6729eadb3b0d
2026-07-06T14:48:17Z 2026-07-06T14:47:58Z 9936ddf ghcr.io/rmi/stitch-stitch-llm:pr-159 ghcr.io/rmi/stitch-stitch-llm:pr-159@sha256:ddfc7cc9bcb8e8c4a26595655a01737f6ba954b73eb15a7bab145cd1721d9c0c

@AlexAxthelm AlexAxthelm requested review from jdhoffa and mbarlow12 July 6, 2026 15:08
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

CD summary 4d41ddf

Frontend: https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-159-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net
stitch-llm open pr-159-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_159 stitch-dev.postgres.database.azure.com 5432 pr_159
Jobs (1)
job image postgres_db
db-migrations ghcr.io/rmi/stitch-api:pr-159@sha256:b8003427f6019621e9c199c5c178c4d345d13f3366f16171d90d2910ee0b113e pr_159
Images (4)
build_time commit_time git_sha image image_digest
2026-07-06T14:47:45Z 2026-07-06T14:47:26Z 7bd2765 ghcr.io/rmi/stitch-api:pr-159 ghcr.io/rmi/stitch-api:pr-159@sha256:b8003427f6019621e9c199c5c178c4d345d13f3366f16171d90d2910ee0b113e
2026-07-06T14:47:45Z 2026-07-06T14:47:26Z 7bd2765 ghcr.io/rmi/stitch-entity-linkage:pr-159 ghcr.io/rmi/stitch-entity-linkage:pr-159@sha256:b3ca5606bc5dd6b7f7b58dfe6cddba568cd31aa1e00c08d14077535665ffdf4a
2026-07-06T14:47:46Z 2026-07-06T14:47:26Z 7bd2765 ghcr.io/rmi/stitch-seed:pr-159 ghcr.io/rmi/stitch-seed:pr-159@sha256:922a6ce337f5a88dcaa28c8e34a538c6abcd483546a8f2da523e85a6763b4199
2026-07-06T14:47:45Z 2026-07-06T14:47:26Z 7bd2765 ghcr.io/rmi/stitch-stitch-llm:pr-159 ghcr.io/rmi/stitch-stitch-llm:pr-159@sha256:5fd2b8f9f405ec556a8af96650c88f8e3f589b91954378788974220c82c165a9

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

CD summary 9cf46e2

Frontend: https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr-159-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-159-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-159.westus2.1.azurestaticapps.net
stitch-llm open pr-159-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_159 stitch-dev.postgres.database.azure.com 5432 pr_159
Jobs (1)
job image postgres_db
db-migrations ghcr.io/rmi/stitch-api:pr-159@sha256:d8cb8fc7362ed917e49db02e875668b93d2b9afab66732253deefcf46c301fe1 pr_159
Images (4)
build_time commit_time git_sha image image_digest
2026-07-06T16:25:43Z 2026-07-06T16:24:07Z a6e9208 ghcr.io/rmi/stitch-api:pr-159 ghcr.io/rmi/stitch-api:pr-159@sha256:d8cb8fc7362ed917e49db02e875668b93d2b9afab66732253deefcf46c301fe1
2026-07-06T16:25:45Z 2026-07-06T16:24:07Z a6e9208 ghcr.io/rmi/stitch-entity-linkage:pr-159 ghcr.io/rmi/stitch-entity-linkage:pr-159@sha256:7f05ce7e2993817475d8167b7aa037b1ed961605d98f53a77043c63f451b708d
2026-07-06T16:25:43Z 2026-07-06T16:24:07Z a6e9208 ghcr.io/rmi/stitch-seed:pr-159 ghcr.io/rmi/stitch-seed:pr-159@sha256:3e2aeef84ab134b57689ec3600e2f91f9e27c30459031003210749c371b6f28a
2026-07-06T16:25:46Z 2026-07-06T16:24:07Z a6e9208 ghcr.io/rmi/stitch-stitch-llm:pr-159 ghcr.io/rmi/stitch-stitch-llm:pr-159@sha256:c4d9f9569f803b95ad1491a471a44e2565bc06c1226c3ba7712d8ec7d873f388

@mbarlow12 mbarlow12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing I noticed is that we're already populating a full list of source data when a user hits the {id}/detail endpoint, responding with OGFieldDetailView. Its source_data attribute has all the data we need to display the list of values for a given attribute with the exception of the actual priority number, but the sources are already sorted in priority order. Unless we need to display "1/2/3/4/...", I think the dropdown could be displayed in pure JS without a second API call.

Comment thread deployments/stitch-frontend/src/hooks/useResources.js
)


async def field_source_values(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a separate endpoint? The OGFieldDetailView already has a full list of sources, sorted in priority order. Could we drop the extra API call & endpoint if we use that data?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a finer grained endpoint, since we'll need to move away from the idea that a resource only has a single set of priorities, and to the idea that each field has its own set of priorities (so the priorities for "Basin" and "Local name" may be differently ordered).

To that end, I think dropping the full list of sources from the OGFieldDetailView is probably a good call moving forward (or at least don't imply that it's an ordered set), and if we need source details, we can fetch those as needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop the full list of sources, then the Detail view becomes just the ListItemView and forces us to make calls for every field attribute the user wants to view. Any other service will need to do the same to get the full, equivalent data for a Field.

const validId = Number.isFinite(numericId);
const endpoint = "oil-gas-fields";
const {
data: detailView,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're waiting here to load the full resource view as it is. Why not fetch data per attribute in pure JS?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is related to the other comment about needing a finer grain on the priority details, and possibly dropping some detail from the details endpoint

@AlexAxthelm AlexAxthelm self-assigned this Jul 7, 2026
@AlexAxthelm AlexAxthelm requested a review from mbarlow12 July 7, 2026 09:13
@jdhoffa

jdhoffa commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@mbarlow12 just noting that you reviewed without approval just now. Could you please flag if any of your comments were specifically blocking here (and if so, which ones?)

@mbarlow12

Copy link
Copy Markdown
Contributor

@mbarlow12 just noting that you reviewed without approval just now. Could you please flag if any of your comments were specifically blocking here (and if so, which ones?)

I'll approve to get things moving, but I'm still not entirely convinced we need an extra endpoint with the additional models.

Even with the upcoming reprioritization PR, our relatively expensive query still gets executed to produce the OGFieldDetailView. That query also already takes into account the priority values. All the data we need is there, but it's not quite structured properly. I'd advocate for adjusting the shape of the detail view and tweaking our coalescing/SQL (which we still have to do regardless of the dropdown display) over adding a separate endpoint (+ new models, wiring, dependencies, permissions) that ultimately calls the same function ResourceModel.source_data_by_resource_id that does the heavy lifting on the db side of things.

The big catch here is that if stitch-llm or entity-linkage (or another service) need to fetch an equivalent detail view for a resource, it'll need to make separate calls for each attribute it needs to see. It just seems easier and more consistent to alter the OGFieldDetailView now that its structure is invalid if there are any attribute-level overrides.

@jdhoffa

jdhoffa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

I'll approve to get things moving, but I'm still not entirely convinced we need an extra endpoint with the additional models.

Even with the upcoming reprioritization PR, our relatively expensive query still gets executed to produce the OGFieldDetailView. That query also already takes into account the priority values. All the data we need is there, but it's not quite structured properly. I'd advocate for adjusting the shape of the detail view and tweaking our coalescing/SQL (which we still have to do regardless of the dropdown display) over adding a separate endpoint (+ new models, wiring, dependencies, permissions) that ultimately calls the same function ResourceModel.source_data_by_resource_id that does the heavy lifting on the db side of things.

The big catch here is that if stitch-llm or entity-linkage (or another service) need to fetch an equivalent detail view for a resource, it'll need to make separate calls for each attribute it needs to see. It just seems easier and more consistent to alter the OGFieldDetailView now that its structure is invalid if there are any attribute-level overrides.

That's totally fair, @mbarlow12 can you please open a ticket under the Tech Debt epic outlining your concerns (ideally in some detail, and referencing this PR) so that we can explore in a future sprint? And can you please add a comment to this PR with the resulting ticket linked?

In general, I don't want to block something that "works" in favour of something that's "perfect", but I still think it's relevant to capture these qualms in detail so that we can follow up on them

@AlexAxthelm AlexAxthelm merged commit 650663a into main Jul 9, 2026
35 checks passed
@AlexAxthelm AlexAxthelm deleted the feat/see-source-values branch July 9, 2026 11:04
@AlexAxthelm

Copy link
Copy Markdown
Collaborator Author

@mbarlow12 just noting that you reviewed without approval just now. Could you please flag if any of your comments were specifically blocking here (and if so, which ones?)

I'll approve to get things moving, but I'm still not entirely convinced we need an extra endpoint with the additional models.

Even with the upcoming reprioritization PR, our relatively expensive query still gets executed to produce the OGFieldDetailView. That query also already takes into account the priority values. All the data we need is there, but it's not quite structured properly. I'd advocate for adjusting the shape of the detail view and tweaking our coalescing/SQL (which we still have to do regardless of the dropdown display) over adding a separate endpoint (+ new models, wiring, dependencies, permissions) that ultimately calls the same function ResourceModel.source_data_by_resource_id that does the heavy lifting on the db side of things.

The big catch here is that if stitch-llm or entity-linkage (or another service) need to fetch an equivalent detail view for a resource, it'll need to make separate calls for each attribute it needs to see. It just seems easier and more consistent to alter the OGFieldDetailView now that its structure is invalid if there are any attribute-level overrides.

I'm generally on board with this, if we can find an ergonomic way of including the full data in the OGFieldDetailView call. I didn't want to start adding weight to that that for something that may or may not end up needed in a particular user's session.

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.

4 participants