talonhub / community

Voice command set for Talon, community-supported.
MIT License
596 stars 761 forks source link

try to avoid calling actions from update_decls callbacks #658

Open rntz opened 2 years ago

rntz commented 2 years ago

in lang/talon/talon.py we call actions.user.create_spoken_forms_from_list from an "update_decls" callback. https://github.com/knausj85/knausj_talon/blob/master/lang/talon/talon.py#L59

This has a complicated interaction that causes an error similar to that in https://github.com/talonvoice/talon/issues/429 to occur. we can temporarily solve this by using Any instead of T, but that's just papering over the underlying problem. (We should still do it though.)

Had a long discussion with aegis on slack about this, starting at https://talonvoice.slack.com/archives/CJ2EE3LEB/p1637107224077200. Resolution seems to be: calling actions from an update_decls callback is a bad idea, we should find a way to avoid it. aegis is considering banning calling actions from these callbacks.

Ways to avoid it:

aegis suggests that eventually create_spoken_forms might go away (I assume he means "become a talon feature", but not sure), so it might be okay if the solution here isn't the prettiest for now.

lunixbochs commented 2 years ago

I thought of a possible solution on my side, which is instead of banning actions in update_decls, I use stale decls for actions called at that point (stale = the actions that were present before the reload). Unsure if viable but it would mean no changes needed in knausj_talon if it worked.