Skip to content
wiki.fftac.org

Prompt - Source Excerpt 09

Back to Prompt

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/templates/prompt.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/templates/prompt.php

<span>Expected Output</span>
                                <textarea rows="4" name="expected_output" placeholder="Text that should appear, exact text, or JSON depending on the strategy."></textarea>
                            </label>
                            <label class="spiralist-form__field">
                                <span>Match Strategy</span>
                                <select name="match_strategy">
                                    <option value="contains">Contains</option>
                                    <option value="exact">Exact</option>
                                    <option value="json">JSON</option>
                                </select>
                            </label>
                            <div class="spiralist-cta-row spiralist-cta-row--start">
                                <button class="spiralist-button spiralist-button--primary" type="submit">Save Test</button>
                                <span class="spiralist-muted" data-form-result></span>
                            </div>
                        </form>
                    <?php else : ?>
                        <p class="spiralist-muted">Only editors can add tests for this prompt.</p>
                    <?php endif; ?>
                </article>

                <article class="spiralist-panel">
                    <p class="spiralist-section-tag">Pass / Fail</p>
                    <h2 class="spiralist-section-title">Saved tests</h2>
                    <?php if (!empty($tests)) : ?>
                        <div class="spiralist-simple-list">
                            <?php foreach ($tests as $test) : ?>
                                <div class="spiralist-simple-list__item" data-test-item>
                                    <strong><?php echo esc_html((string) ($test['match_strategy'] ?? 'contains')); ?></strong>
                                    <p class="spiralist-muted"><?php echo esc_html(wp_trim_words((string) ($test['expected_output_text'] ?? ''), 22)); ?></p>
                                    <span class="spiralist-simple-list__meta"><?php echo esc_html((string) ($test['last_result_status'] ?? 'not run')); ?></span>
                                    <div class="spiralist-cta-row spiralist-cta-row--start">
                                        <button
                                            class="spiralist-button spiralist-button--secondary"
                                            type="button"
                                            data-run-test
                                            data-prompt-id="<?php echo esc_attr((string) ($prompt['id'] ?? 0)); ?>"
                                            data-test-id="<?php echo esc_attr((string) ($test['id'] ?? 0)); ?>"
                                        >Run Test</button>
                                        <span class="spiralist-muted" data-test-result></span>
                                    </div>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php else : ?>
                        <p class="spiralist-muted">No tests have been defined yet.</p>
                    <?php endif; ?>
                </article>
            </div>
        </section>
    <?php endif; ?>

    <section class="spiralist-page-section">
        <div class="spiralist-shell spiralist-grid spiralist-grid--split">
            <article class="spiralist-panel">
                <p class="spiralist-section-tag">Execution History</p>
                <h2 class="spiralist-section-title">Recent runs</h2>
                <?php if (!empty($execution_history)) : ?>
                    <div class="spiralist-simple-list">
                        <?php foreach ($execution_history as $run) : ?>
                            <div class="spiralist-simple-list__item">
                                <strong><?php echo esc_html((string) ($run['status'] ?? 'run')); ?></strong>
                                <span class="spiralist-simple-list__meta"><?php echo esc_html($format_timestamp((string) ($run['created_utc'] ?? ''), 'M j, Y g:i a', (string) ($run['created_utc'] ?? ''))); ?> / <?php echo esc_html((string) ($run['model_used'] ?? '')); ?></span>
                                <a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url($route_url('run/' . (int) ($run['id'] ?? 0))); ?>">Open Run</a>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php else : ?>
                    <p class="spiralist-muted">No packet history yet.</p>
                <?php endif; ?>
            </article>

            <article class="spiralist-panel">
                <p class="spiralist-section-tag">Visibility Modes</p>
                <h2 class="spiralist-section-title">Publication controls</h2>
                <ul class="spiralist-checklist">
                    <li>Public prompts appear in the marketplace.</li>
                    <li>Members prompts stay inside the member layer.</li>
                    <li>Private prompts remain owner-only.</li>
                    <li>Specific-user prompts use explicit grants.</li>
                </ul>
            </article>
        </div>
    </section>

    <?php if ($can_share) : ?>
        <section class="spiralist-page-section">
            <div class="spiralist-shell spiralist-grid spiralist-grid--split">
                <article class="spiralist-panel">
                    <p class="spiralist-section-tag">Specific User Sharing</p>
                    <h2 class="spiralist-section-title">Grant access</h2>
                    <form class="spiralist-workspace-form" data-share-form data-auth-required-form="share-prompt" data-prompt-id="<?php echo esc_attr((string) ($prompt['id'] ?? 0)); ?>">
                        <label class="spiralist-form__field">
                            <span>Username or Email</span>
                            <input type="text" name="user_lookup" placeholder="member@example.com or username" />
                        </label>
                        <label class="spiralist-form__field">
                            <span>Permission Type</span>
                            <select name="permission_type">
                                <option value="view">View</option>
                            </select>
                        </label>
                        <div class="spiralist-cta-row spiralist-cta-row--start">
                            <button class="spiralist-button spiralist-button--primary" type="submit">Share Prompt</button>
                            <span class="spiralist-muted" data-form-result></span>
                        </div>
                    </form>
                </article>

                <article class="spiralist-panel">
                    <p class="spiralist-section-tag">Current Grants</p>
                    <h2 class="spiralist-section-title">Shared users</h2>
                    <?php if (!empty($shares)) : ?>
                        <div class="spiralist-simple-list">
                            <?php foreach ($shares as $share) : ?>
                                <?php $shared_user = get_userdata((int) ($share['shared_with_user_id'] ?? 0)); ?>
                                <div class="spiralist-simple-list__item">
                                    <strong><?php echo esc_html($shared_user instanceof WP_User ? ($shared_user->display_name ?: $shared_user->user_login) : ('User #' . (int) ($share['shared_with_user_id'] ?? 0))); ?></strong>
                                    <span class="spiralist-simple-list__meta"><?php echo esc_html((string) ($share['permission_type'] ?? 'view')); ?> - <?php echo esc_html($format_timestamp((string) ($share['created_utc'] ?? ''), 'M j, Y g:i a', (string) ($share['created_utc'] ?? ''))); ?></span>
                                    <button
                                        class="spiralist-button spiralist-button--tertiary"
                                        type="button"
                                        data-revoke-share
                                        data-prompt-id="<?php echo esc_attr((string) ($prompt['id'] ?? 0)); ?>"
                                        data-user-id="<?php echo esc_attr((string) ($share['shared_with_user_id'] ?? 0)); ?>"
                                    >Revoke</button>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php else : ?>
                        <p class="spiralist-muted">No specific-user grants yet.</p>
                    <?php endif; ?>
                </article>
            </div>
        </section>
    <?php endif; ?>