-
Notifications
You must be signed in to change notification settings - Fork 399
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
[#2319] Fix Assistant utility types #2325
Conversation
say: SayFn; | ||
setStatus: SetStatusFn; | ||
setSuggestedPrompts: SetSuggestedPromptsFn; | ||
setTitle: SetTitleFn; | ||
} | ||
|
||
type GetThreadContextUtilFn = () => Promise<AssistantThreadContext>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the ongoing issue with non-ack'd events, it appears to work as expected. This update corresponds to the enrich function. I believe I've gotten the pass-through correct:
// Do not pass preparedArgs (ie, do not add utilities to get/save)
preparedArgs.getThreadContext = () => threadContextStore.get(args);
preparedArgs.saveThreadContext = () => threadContextStore.save(args);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and this signature matches the assertion expectations in the matching tests 💯
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2325 +/- ##
=======================================
Coverage 91.08% 91.08%
=======================================
Files 22 22
Lines 6116 6116
Branches 655 655
=======================================
Hits 5571 5571
Misses 540 540
Partials 5 5 ☔ View full report in Codecov by Sentry. |
@@ -310,7 +310,7 @@ function createSay(args: AllAssistantMiddlewareArgs): SayFn { | |||
const { channelId: channel, threadTs: thread_ts, context } = extractThreadInfo(payload); | |||
|
|||
return async (message: Parameters<SayFn>[0]) => { | |||
const threadContext = context.channel_id ? context : await args.getThreadContext(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since args
is passed through in the enrich function, the removal of this additional pass-through shouldn't have an effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh nice catch. This took me a while to parse - I kept confusing the middleware arguments' getThreadContext
method with ThreadContextStore.get
.
}, | ||
}); | ||
|
||
// threadContextStore tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filmaj Covered all class props, but let me know if I'm missing anything glaring or need to adjust the approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests look great, they cover all the utility functions mentioned in #2319 so I'm happy 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
}, | ||
}); | ||
|
||
// threadContextStore tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests look great, they cover all the utility functions mentioned in #2319 so I'm happy 👍
say: SayFn; | ||
setStatus: SetStatusFn; | ||
setSuggestedPrompts: SetSuggestedPromptsFn; | ||
setTitle: SetTitleFn; | ||
} | ||
|
||
type GetThreadContextUtilFn = () => Promise<AssistantThreadContext>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and this signature matches the assertion expectations in the matching tests 💯
@@ -310,7 +310,7 @@ function createSay(args: AllAssistantMiddlewareArgs): SayFn { | |||
const { channelId: channel, threadTs: thread_ts, context } = extractThreadInfo(payload); | |||
|
|||
return async (message: Parameters<SayFn>[0]) => { | |||
const threadContext = context.channel_id ? context : await args.getThreadContext(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh nice catch. This took me a while to parse - I kept confusing the middleware arguments' getThreadContext
method with ThreadContextStore.get
.
Summary
Fixes #2319. Adds type tests (courtesy of @filmaj).
Requirements (place an
x
in each[ ]
)