Document why PropsSchema.json works that way it does or change it
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3562095. -->
Reported by: [tedbow](https://www.drupal.org/user/240860)
>>>
<h3 id="overview">Overview</h3>
<p>Reviewing <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3555154" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3555154</a></span> I confused what modules/canvas_ai/src/PropsSchema.json is actually used for.</p>
<p>If you search modules/canvas_ai for "PropsSchema.json" or just "PropsSchema" you wouldn't find any results.<br>
So at first I thought this wasn't used but then I found it is referenced in ui/src/components/aiExtension/AiWizard.tsx</p>
<p><code>import fixtureProps from '../../../../modules/canvas_ai/src/PropsSchema.json';</code><br>
This weird because this is the only case where our js is importing files from the php src directory</p>
<p>Weirder is the client doesn't actually use these values it just appends to the request as `derived_proptypes`, No other client code references this.</p>
<p>Where this is used is \Drupal\canvas_ai\Controller\CanvasBuilder::render in a call to \Drupal\ai_agents\PluginBase\AiAgentEntityWrapper::setTokenContexts</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #DD0000">'derived_proptypes' </span><span style="color: #007700">=> isset(</span><span style="color: #0000BB">$prompt</span><span style="color: #007700">[</span><span style="color: #DD0000">'derived_proptypes'</span><span style="color: #007700">]) ? </span><span style="color: #0000BB">Json</span><span style="color: #007700">::</span><span style="color: #0000BB">encode</span><span style="color: #007700">(</span><span style="color: #0000BB">$prompt</span><span style="color: #007700">[</span><span style="color: #DD0000">'derived_proptypes'</span><span style="color: #007700">]) : </span><span style="color: #0000BB">NULL</span><span style="color: #007700">,<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>and $prompt['derived_proptypes'] is just decoded from the request. </p>
<p>so I am confused as to why</p>
<ol>
<li>the client imports modules/canvas_ai/src/PropsSchema.json which is in a php src code directory,</li>
<li>appends it to the request without doing anything else with it</li>
<li>the server side code decodes and uses this for a token value</li>
</ol>
<p>If only the server needs this why doesn't it just decode modules/canvas_ai/src/PropsSchema.json directly? Why does it need to do come from the client at all</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>Either</p>
<ol>
<li>Add comments in appropriate places as to why the current workflow is needed</li>
<li>Move PropsSchema.json out of source into canvas_ai/assets/PropsSchema.json and have \Drupal\canvas_ai\Controller\CanvasBuilder::render just decode canvas_ai/assets/PropsSchema.json directly without it coming from the client.
</li></ol>
<h3 id="ui-changes">User interface changes</h3>
<p>none</p>
> Related issue: [Issue #3555154](https://www.drupal.org/node/3555154)
issue