Skip to content

Update learned facts #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Update learned facts #70

merged 1 commit into from
Apr 7, 2025

Conversation

d3vco
Copy link
Contributor

@d3vco d3vco commented Apr 7, 2025

Description

Ensures that learned facts are displayed for selection in the AddPotentialLinkModal

Current Behavior

In the current design, operations and sources are collect in the onMounted hook:

onMounted(async () => {
await agentStore.getAgents($api);
if (agentStore.agents.length > 0 && canSelectAgent) {
filters.agent = agentStore.agents[0];
filters.executor = filters.agent.executors[0];
} else {
filters.agent = props.agent.paw;
filters.executor = filters.agent.executors[0];
}
await abilityStore.getAbilities($api);
await sourceStore.getSources($api);
await operationStore.getFacts($api);
});

And then later, these objects are used to collect the imported facts and learned facts:

const opSource = sources.value.find((s) => s.id === props.operation.source.id);
const opSourceCollected = sources.value.find((source) => source.name === props.operation.name);
const facts = (opSource.facts.concat(opSourceCollected ? opSourceCollected.facts : [])).concat(operationStore.facts);

However, this design doesn't achieve the designed behavior because the AddPotentialLinkModal is only mounted once and then hidden/shown when the + Potential Link button is pressed. Therefore, the getFacts function is not called again and the learned facts are not updated.

New Behavior

The getFacts call is moved inside the selectedPotentialLink function, so it is called every time an ability is selected. This updates the facts array prior to displaying the screen where values can be selected.

Note 1: In this change, I also updated the sources that make up the facts. Previously, the facts were drawn from 3 sources:

  1. The fact source associated with the operation (the source selected when creating the new operation)
  2. The facts learned during the operation
  3. The fact source generated by the operation

In this update I removed source 3 from the list above because this is a replica of sources 1 and 2 and causes all facts to be duplicated. If there is a reason to retain this feature, it can be re-added.

Note 2: The AddPotentialLinkModal retains the state of the last use of the modal. So if a user adds a Potential Link and then returns to the modal to add the same link again, the facts will not update unless the user goes back and re-selects the same ability.

@elegantmoose elegantmoose self-assigned this Apr 7, 2025
@elegantmoose elegantmoose self-requested a review April 7, 2025 19:45
@elegantmoose elegantmoose merged commit ee07189 into mitre:master Apr 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants