Skip to content
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

Merged
merged 4 commits into from
Nov 12, 2024
Merged

Conversation

misscoded
Copy link
Contributor

Summary

Fixes #2319. Adds type tests (courtesy of @filmaj).

Requirements (place an x in each [ ])

@misscoded misscoded added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch TypeScript-specific labels Nov 7, 2024
@misscoded misscoded requested a review from filmaj November 7, 2024 21:43
@misscoded misscoded self-assigned this Nov 7, 2024
say: SayFn;
setStatus: SetStatusFn;
setSuggestedPrompts: SetSuggestedPromptsFn;
setTitle: SetTitleFn;
}

type GetThreadContextUtilFn = () => Promise<AssistantThreadContext>;
Copy link
Contributor Author

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);

Copy link
Contributor

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 💯

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.08%. Comparing base (6dedf1d) to head (eb8b021).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@@ -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);
Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor Author

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.

Copy link
Contributor

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 👍

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

},
});

// threadContextStore tests
Copy link
Contributor

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>;
Copy link
Contributor

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);
Copy link
Contributor

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.

@misscoded misscoded merged commit 2f25b21 into main Nov 12, 2024
20 checks passed
@misscoded misscoded deleted the 2319-fix-assistant-util-types branch November 12, 2024 19:41
@filmaj filmaj added this to the 4.1.1 milestone Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch TypeScript-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Would the argument for getThreadContext and saveThreadContext be unnecessary?
2 participants