Skip to content

Don't discard everyScope selections for multiple targets #2893

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented Apr 17, 2025

Unfortunately became quite a lot of changes to pass the modifier options, but I think this is the only way. It also opens up for more context aware modifiers in the future.

Fixes #2889

Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

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

Wow this touched a lot of code for such a small edge case. Would it make any sense to pass into the stage constructor instead? Would that help?

I'm also not totally convinced by this fix. Eg what if you have

aaa bbb
ccc ddd

And you say "take bat and drum" and then say "take first token". Would you really expect that to behave differently from "take bat" followed by "take first token"?

I think a better heuristic would be whether all the inputs have the same number of scopes. Ie our current hack/heuristic should either apply to all input targets or none. But that does start to feel maybe hard to reason about?

@AndreasArvidsson
Copy link
Member Author

AndreasArvidsson commented Apr 19, 2025

Wow this touched a lot of code for such a small edge case. Would it make any sense to pass into the stage constructor instead? Would that help?

I don't think that would touch less files. There's a lot of instances where we create a modifier stage and then call it directly after.

I'm also not totally convinced by this fix. Eg what if you have

aaa bbb
ccc ddd

And you say "take bat and drum" and then say "take first token". Would you really expect that to behave differently from "take bat" followed by "take first token"?

True

I think a better heuristic would be whether all the inputs have the same number of scopes. Ie our current hack/heuristic should either apply to all input targets or none. But that does start to feel maybe hard to reason about?

You mean we would actually run the modify stage on each target and then compare the results. If needed rerun the state with different settings? This would be a level of interaction between the different paths of our pipeline we have never done before. I'm not sure if that is simpler or more complicated for the user either.

@AndreasArvidsson
Copy link
Member Author

@pokey I thought some more on the idea of the different instances of the modifier being more aware of each other. My first was to add a optional function runMultiple on the modifier interface. Then the every scope modifier could handle that internally. That would be no problem at all if it was only called from the pipeline, but we have lovely pieces of code like getEveryScopeTargets where the ordinal modifier relies on the every modifier. At that point we only have a single target. Passing an option object through the way I'm already doing in this pull request is fine, but bubbling an exception or similar all the way from the every modifier all the way through getEveryScopeTargets to the ordinal modifier increases complexity quite a lot.

export function getEveryScopeTargets(
modifierStageFactory: ModifierStageFactory,
target: Target,
scopeType: ScopeType,
): Target[] {
const containingStage = modifierStageFactory.create({
type: "everyScope",
scopeType,
});
return containingStage.run(target);
}

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.

Unexpected token appears to be included when I say 'flash every token this'
2 participants