Skip to content

AI Tutor - Refactor PR #68567 to align with AiTutorContextHelper class intentions#68589

Merged
edcodedotorg merged 1 commit into
molly/files-context-weblab2from
ed/files-context-weblab2-refactor
Sep 26, 2025
Merged

AI Tutor - Refactor PR #68567 to align with AiTutorContextHelper class intentions#68589
edcodedotorg merged 1 commit into
molly/files-context-weblab2from
ed/files-context-weblab2-refactor

Conversation

@edcodedotorg

Copy link
Copy Markdown
Contributor

This PR is a small refactor to align PR #68567 with the intentions of AiTutorContextHelper. A secondary nit that was addressed was to change UserAddedContext to UserAddedSelectionContext to further describe the additional context (code that the user "selects") that the user is adding.

Re: intentions of AiTutorContextHelper

The AiTutorContextHelper class is designed to be aware of a uniform set of context items that can be opted into by each lab / use-case. How the context item is formatted / added to the final context string is handled by getHiddenContextString, so the idea is that if something is only opted-into by a given lab that is fine, but if opted-in, it should be handled uniformly without having to provide any new lab-specific methods in the derived class.

The class is already pretty flexible in that it is a templated class and each use-case can provide its own internal data structure as a generic type parameter (T). Rather than defining a use-case specific getHiddenContextCallbackWebLab2, the additional context has been added to the WebLab2 specific type and its setAiTutorContext turns this specific context into a generic userSelection that is now an optional property of AiTutorContext and can be handled in the base class:

interface AiTutorWebLab2Params {
  source: MultiFileSource | undefined;
  longInstructions: string | undefined;
  selection: UserAddedSelectionContext;
}

I will cut the explanation short in the interest of time (the original PR is somewhat urgent), but if anyone has any questions or concerns, just let me know.

PR Creation Checklist:

  • Tests provide adequate coverage
  • Privacy impacts have been documented
  • Security impacts have been documented
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Follow-up work items (including potential tech debt) are tracked and linked

@molly-moen molly-moen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Feel free to merge into my branch

@edcodedotorg edcodedotorg merged commit 0415c37 into molly/files-context-weblab2 Sep 26, 2025
2 of 3 checks passed
@edcodedotorg edcodedotorg deleted the ed/files-context-weblab2-refactor branch September 26, 2025 20:35
molly-moen added a commit that referenced this pull request Sep 26, 2025
* some initial plumbing

* more plumbing

* wip

* getting files to show up

* create context in redux

* start plumbing through redux

* use new context

* clear context after sending

* clean up and add file path

* add context to chat history

* small updates

* clean up

* undo csp change

* refactor to align with AiTutorContextHelper class intentions (#68589)

* add key

* fix close icon and clear context on level switch

---------

Co-authored-by: Ed Baafi <edward.baafi@code.org>
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.

2 participants