Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 2652716

Browse files
authored
UX: improve artifact styling add direct share link (#930)
Also remove uneeded sandboxing give this is all handled by artifacts directly
1 parent a0aec48 commit 2652716

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

app/controllers/discourse_ai/ai_bot/artifacts_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def show
5252
padding: 0;
5353
width: 100%;
5454
height: 100%;
55+
border: 0;
56+
overflow: hidden;
57+
}
58+
iframe {
59+
overflow: auto;
5560
}
5661
</style>
5762
</head>

app/models/ai_artifact.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ class AiArtifact < ActiveRecord::Base
99

1010
def self.iframe_for(id)
1111
<<~HTML
12-
<iframe sandbox="allow-scripts allow-forms" height="600px" src='#{url(id)}' frameborder="0" width="100%"></iframe>
12+
<div class='ai-artifact'>
13+
<iframe src='#{url(id)}' frameborder="0" height="100%" width="100%"></iframe>
14+
<a href='#{url(id)}' target='_blank'>#{I18n.t("discourse_ai.ai_artifact.link")}</a>
15+
</div>
1316
HTML
1417
end
1518

assets/javascripts/discourse/components/ai-artifact.gjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export default class AiArtifactComponent extends Component {
104104
src={{this.artifactUrl}}
105105
width="100%"
106106
frameborder="0"
107-
sandbox="allow-scripts allow-forms"
108107
></iframe>
109108
{{/if}}
110109
{{#unless this.requireClickToRun}}

config/locales/server.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ en:
173173
title: Surprise
174174

175175
discourse_ai:
176+
ai_artifact:
177+
link: "Show Artifact in new tab"
176178
unknown_model: "Unknown AI model"
177179

178180
tools:

public/ai-share/share.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ aside .title .avatar {
441441
}
442442

443443
.lightbox-wrapper .meta .filename,
444-
.lightbox-wrapper .meta svg,
444+
.lightbox-wrapper .meta svg,
445445
.lightbox-wrapper .meta .informations {
446446
display: none;
447447
}
@@ -450,20 +450,20 @@ aside .title .avatar {
450450
overflow-wrap: anywhere;
451451
}
452452

453-
/*
454-
custom code highlighting for dark mode support...
455-
overrides highlightjs (https://highlightjs.org/) CSS colors.
456-
*/
453+
/*
454+
custom code highlighting for dark mode support...
455+
overrides highlightjs (https://highlightjs.org/) CSS colors.
456+
*/
457457

458458
.hljs{
459459
--hljs-red: #c63c1b;
460460
--hljs-salmon: #ec8972;
461461
--hljs-lime: #4dff4d;
462462
--hljs-green: #090;
463463
--hljs-sky: #47c2ff;
464-
464+
465465
@media (prefers-color-scheme: dark) {
466-
--hljs-red: #af3719;
466+
--hljs-red: #af3719;
467467
--hljs-salmon: #c7705c;
468468
--hljs-lime: #3fcf3f;
469469
--hljs-green: #048504;
@@ -614,16 +614,21 @@ aside.onebox h3 {
614614
display: block;
615615
background-size: contain;
616616
background-repeat: no-repeat;
617-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3C!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--%3E%3Cpath d='M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z' fill='white' /%3E%3C/svg%3E");
617+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3C!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--%3E%3Cpath d='M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z' fill='white' /%3E%3C/svg%3E");
618618
z-index: 2;
619619
width: 5em;
620620
height: 6.25em;
621621
left: 0;
622622
right: 0;
623623
top: 32%;
624624
pointer-events: none;
625-
margin-left: auto;
626-
margin-right: auto;
625+
margin-left: auto;
626+
margin-right: auto;
627627
opacity: 0.85;
628628
transition: opacity 0.25s ease-in-out;
629-
}
629+
}
630+
631+
.ai-artifact iframe {
632+
height: 600px;
633+
max-height: 600px;
634+
}

0 commit comments

Comments
 (0)