fix: refactor function handler for follow up auto ack behavior#2424
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2424 +/- ##
==========================================
+ Coverage 92.59% 92.97% +0.37%
==========================================
Files 36 36
Lines 7472 7441 -31
Branches 653 652 -1
==========================================
- Hits 6919 6918 -1
+ Misses 545 518 -27
+ Partials 8 5 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
@WilliamBergamin Lots of awesome changes are happening here! I'm also hopeful that these will make later additions and future maintenance more clear 🙏 ✨
I left handfuls of comments for now with suggestions and thoughts, but nothing seems to be so blocking. A few notes around typings might be worth considering though!
It took me a bit to familiarize myself with parts of this code, but tomorrow I plan to review the test changes. Thank you in advanced for these changes and care for the code 👾
| // If functionBotAccessToken exists on context, the incoming event is function-related *and* the | ||
| // user has `attachFunctionToken` enabled. In that case, subsequent calls with the client should | ||
| // use the function-related/JIT token in lieu of the botToken or userToken. | ||
| const token = context.functionBotAccessToken ? context.functionBotAccessToken : selectToken(context); |
There was a problem hiding this comment.
@WilliamBergamin Super nice catch here! It seems like attachFunctionToken might've been ignored before these changes 👁️🗨️
📝 Moving all of this logic into selectToken is also a nice change that aligns with the expected behavior noted in #2500!
There was a problem hiding this comment.
📣 Following up on this with #2513 since changes to selectToken allow us to share this token in context without unexpected overrides I believe!
There was a problem hiding this comment.
Thanks for creating #2513 🙇 I left one comment and I've approved it 🟢
| // Factory for say() utility | ||
| const createSay = (channelId: string): SayFn => { | ||
| const token = selectToken(context); | ||
| const token = selectToken(context, this.attachFunctionToken); |
There was a problem hiding this comment.
🤔 Thinking aloud here, but I'm wondering if inlining createSay might allow us to use the same token from below and perhaps even a client from the pool:
Lines 1117 to 1120 in d61f2cd
AFAICT we do not use this factory function in other places. No blocker since we're overriding the token in these arguments at the moment, though perhaps that wouldn't be needed?
There was a problem hiding this comment.
This is a great point 💯 but I think we should dedicate a specific PR for this change, since the scope of these changes is already large
I added a TODO comment for this
zimeg
left a comment
There was a problem hiding this comment.
📝 Leaving another note of a related change in mind from another PR!
I'm also wondering if this is a patch change, since at a glance no changes to behavior were noticed in testing. Though I still have not reviewed the tests 😉
| // If functionBotAccessToken exists on context, the incoming event is function-related *and* the | ||
| // user has `attachFunctionToken` enabled. In that case, subsequent calls with the client should | ||
| // use the function-related/JIT token in lieu of the botToken or userToken. | ||
| const token = context.functionBotAccessToken ? context.functionBotAccessToken : selectToken(context); |
There was a problem hiding this comment.
📣 Following up on this with #2513 since changes to selectToken allow us to share this token in context without unexpected overrides I believe!
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
zimeg
left a comment
There was a problem hiding this comment.
@WilliamBergamin Thanks so much for sifting through all of those comments! 🤖
Another pass at reviewing and more test runs with a sample app have me excited for these changes.
I left two more comments around documentation and test cases that would be nice to include before merging this, but once the time is right please feel free to merge 🚢 💨
The improvements to test helpers are a nice addition.
Thank you for your patience in these reviews as well 🙏 ✨
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
Summary
This PR aims to
Manual tests
These changes were manually tested against
bolt-js-custom-step-template -> no breaking change observed 🟢
bolt-ts-starter-template -> no breaking change observed 🟢
Requirements