Skip to content

Conversation

@SimonMilord
Copy link
Contributor

@SimonMilord SimonMilord commented Dec 18, 2025

SFINT-6517

IN THIS PR:

  • Added the Headless Attached Citations controller that will support the attach citations feature.
  • Added unit tests to cover the controller

It supports the following methods:

  • isAttached -> checks in the state if a citation document is attached
  • attach -> attaches a citation document to the attached results state
  • detach -> detaches a citation document from the attached results state

TEST:

image

@SimonMilord SimonMilord changed the base branch from main to SFINT-6550 December 18, 2025 20:22
@github-actions
Copy link

github-actions bot commented Dec 18, 2025

🔗 Scratch Orgs ready to test this PR:

articlePublishStatus: ensureStringOrUndefined(
citation.fields?.sfpublishstatus
),
isCitation: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update this to isAttachedFromCitation

Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

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

Some small suggestions, but otherwise almost ready to merge!

const isCitation = attached.isCitation === true;

return (
caseIdMatches && isCitation && (permanentIdMatches || uriHashMatches)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
caseIdMatches && isCitation && (permanentIdMatches || uriHashMatches)
caseIdMatches && (permanentIdMatches || uriHashMatches)

This is what we discussed right? No matter if it's a citation or not, it's attached.

});
};

const getAttachedResultsForRecord = (): AttachedResult[] => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something I would centralize in an accessor btw, we have the exact same code duplicated in the headless-attached-results.ts

export const selectAttachedResultsForCase =
  (caseId: string) =>
  (state: State): AttachedResult[] =>
    state.attachedResults.results.filter((attached) => attached.caseId === caseId);

// And then use it like this:
const getAttachedResultsForRecord = (): AttachedResult[] =>
  selectAttachedResultsForCase(caseId)(engine.state);

);
};

const validateStringOrUndefined = (value: unknown): string | undefined => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe Bueno exposes something for this already no?

permanentId: citation.permanentid,
resultUrl: citation.clickUri ?? citation.uri,
title: citation.title,
uriHash: validateStringOrUndefined(citation.fields?.urihash),
Copy link
Collaborator

Choose a reason for hiding this comment

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

These will include a bunch of undefined is that what you want?

{
    uriHash: undefined,
    source: undefined,
    ...
}

Comment on lines +170 to +171
const resultToAttach = buildAttachedResultFromCitation(citation);
dispatch(attachResult(resultToAttach));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can omit the intermediate variable if you want, only if you want.

Suggested change
const resultToAttach = buildAttachedResultFromCitation(citation);
dispatch(attachResult(resultToAttach));
dispatch(attachResult(buildAttachedResultFromCitation(citation)));

return typeof value === 'string' ? value : undefined;
};

const buildAttachedResultFromCitation = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe it's an anti-pattern to include this method here,

either you could use the exposed method from the actual component if it's exposed.

Or, you create the object you already expect and don't go through mapping.

Otherwise if the mapping changes in the actual component you have to maintain this part too.

What's important to test is the expectated values, so hardcode that expected value.

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