This repository was archived by the owner on Jul 22, 2025. It is now read-only.
generated from discourse/discourse-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 41
FEATURE: persistent key-value storage for AI Artifacts #1417
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jjaffeux
reviewed
Jun 9, 2025
jjaffeux
reviewed
Jun 9, 2025
jjaffeux
reviewed
Jun 9, 2025
romanrizzi
reviewed
Jun 9, 2025
fix incorrect drift in artifact controller
Co-authored-by: Joffrey JAFFEUX <[email protected]>
cde1510 to
cb93245
Compare
xfalcox
approved these changes
Jun 10, 2025
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a persistent, user-scoped key-value storage system for
AI Artifacts, enabling them to be stateful and interactive. This
transforms artifacts from static content into mini-applications that can
save user input, preferences, and other data.
The core components of this feature are:
Model and API:
AiArtifactKeyValuemodel and corresponding database table tostore data associated with a user and an artifact.
ArtifactKeyValuesControllerprovides a RESTful API forCRUD operations (
index,set,destroy) on the key-value data.can view public data from other users.
Secure JavaScript Bridge:
postMessagecommunication bridge is established between thesandboxed artifact
iframeand the parent Discourse window.window.discourseArtifactwith async methods:
get(key),set(key, value, options),delete(key), andindex(filter).new controller, and returns the results to the iframe. This ensures
security by keeping untrusted JS isolated.
AI Tool Integration:
create_artifacttool is updated with arequires_storageboolean parameter.
system prompt for the code-generating AI is augmented with detailed
documentation for the new storage API.
Configuration:
ai_artifact_kv_value_max_lengthandai_artifact_max_keys_per_user_per_artifactfor throttling.This also includes a minor fix to use
jsonb_setwhen updatingartifact metadata, ensuring other metadata fields are preserved.