Skip to content

Conversation

@camielvs
Copy link
Collaborator

@camielvs camielvs commented Nov 27, 2025

Description

Fixes a bug where pipeline digest did not update in realtime when changes were made to a pipeline.

ComponentSpecProvider now exports a digest calculated dynamically from the spec.

Related Issue and Pull requests

Closes https://github.com/Shopify/oasis-frontend/issues/368

Type of Change

  • Bug fix

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

Test Instructions

Verify that pipeline digest updates when changes are made to a pipeline.
Verify that digest is the same after refreshing or reloading a pipeline.

Additional Comments

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camielvs camielvs requested a review from Mbeaulne November 27, 2025 21:16
@camielvs camielvs marked this pull request as ready for review November 27, 2025 21:16
Copy link
Collaborator

@Mbeaulne Mbeaulne Nov 28, 2025

Choose a reason for hiding this comment

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

I don't think digest is technically part of the component spec. I wonder if we just update the component spec component to generate a component spec for itself instead of having it in context, that way we keep the context a little cleaner and it removes the effect in favour of tanstackQuery.

Here is a vibe coded example. Also this isn't a hill im going to die on, just a suggestion

// src/components/Editor/ComponentDigest.tsx
import { useSuspenseQuery } from "@tanstack/react-query";
import { Suspense, useMemo } from "react";

import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import useToastNotification from "@/hooks/useToastNotification";
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
import { generateDigest } from "@/services/componentService";
import { componentSpecToYaml } from "@/utils/componentStore";

function useComponentSpecDigest() {
const { componentSpec } = useComponentSpec();

const yamlText = useMemo(
() => componentSpecToYaml(componentSpec),
[componentSpec],
);

const { data } = useSuspenseQuery({
queryKey: ["componentSpec", "digest", yamlText],
queryFn: () => generateDigest(yamlText),
staleTime: Infinity,
});

return data;
}

const DigestSkeleton = () => (

  <div class="">
    <h3 class="">Digest</h3>
  </div>
);

const DigestContent = () => {
const digest = useComponentSpecDigest();
const notify = useToastNotification();

return (
<div class=""><h3 class="">Digest</h3>&#x3C;ButtonclassName="bg-gray-100 border border-gray-300 rounded p-2 h-fit text-xs w-full text-left hover:bg-gray-200 active:bg-gray-300 transition cursor-pointer"onClick={() => {navigator.clipboard.writeText(digest);notify("Digest copied to clipboard", "success");}}variant="ghost"><span class="">{digest}</span></div>
);
};

export const ComponentDigest = () => (
\<Suspense fallback={\<DigestSkeleton />}>
\<DigestContent />
\</Suspense>
);  

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did consider whether to do this calculation in the component itself vs the provider. I ultimately put it in the provider because any given component spec is going to have its own unique digest so I thought it might be useful to have one source of truth for the digest.

I'm not sure about using useQuery because the digest is constantly changing so the benefits of caching is low. I think for now I'm going to keep it as-is and we can take a closer look later.

@camielvs camielvs force-pushed the 11-27-componentspecprovider_computes_digest branch from afafd58 to a04fb3d Compare November 28, 2025 19:23
@camielvs camielvs requested a review from Mbeaulne November 28, 2025 19:23
@camielvs camielvs force-pushed the 11-27-componentspecprovider_computes_digest branch 2 times, most recently from 71b05e1 to c3005a6 Compare December 2, 2025 18:17
@camielvs camielvs requested a review from maxy-shpfy December 3, 2025 00:21
Copy link
Collaborator

@Mbeaulne Mbeaulne left a comment

Choose a reason for hiding this comment

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

I still don't think its needed in the componentSpecProvider, but thats not going to stop be from approving! But if Max feels any way, lets discuss then.

@camielvs camielvs force-pushed the 11-27-componentspecprovider_computes_digest branch from c3005a6 to cac5315 Compare December 3, 2025 20:07
Copy link
Collaborator Author

camielvs commented Dec 3, 2025

I will merge and we can follow up later if we decide to go in a different direction.

Copy link
Collaborator Author

camielvs commented Dec 3, 2025

Merge activity

  • Dec 3, 8:10 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 3, 8:10 PM UTC: @camielvs merged this pull request with Graphite.

@camielvs camielvs merged commit 93c5ed4 into master Dec 3, 2025
5 checks passed
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.

3 participants