Skip to content

UN-3386 [FEAT] Add Prompt Studio HITL change indicator plugin slot#1930

Merged
vishnuszipstack merged 5 commits into
mainfrom
UN-3386-prompt-studio-hitl-feedback
May 19, 2026
Merged

UN-3386 [FEAT] Add Prompt Studio HITL change indicator plugin slot#1930
vishnuszipstack merged 5 commits into
mainfrom
UN-3386-prompt-studio-hitl-feedback

Conversation

@vishnuszipstack
Copy link
Copy Markdown
Contributor

@vishnuszipstack vishnuszipstack commented Apr 27, 2026

What

  • Adds a dynamic-import slot in the Prompt Studio prompt-card Header for a new cloud-only PromptChangeIndicator plugin button.
  • Registers a new route :orgName/review/readonly/:documentId gated on a cloud-only ReadOnlyReviewPage plugin.
  • Both gates fall through silently when the plugin is absent (OSS builds remain untouched).

Why

  • Closes the loop between HITL reviewers and prompt authors: when a reviewer corrects a field in HITL, the prompt author should be able to see that signal back in Prompt Studio.
  • The feature lives in the cloud plugin, but the host (OSS) needs to expose the integration points so the indicator and the read-only audit page can be wired up.

How

  • frontend/src/components/custom-tools/prompt-card/Header.jsx: adds a try/catch dynamic import for plugins/prompt-change-indicator/PromptChangeIndicator, renders it (with promptDetails and toolDetails) between ExpandCardBtn and PromptRunBtnSps when present.
  • frontend/src/routes/useMainAppRoutes.js: adds a parallel try/catch dynamic import for plugins/prompt-change-indicator/ReadOnlyReviewPage, registers review/readonly/:documentId inside the existing ReviewLayout group when present.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

  • No. The new code paths are guarded by if (PluginName) { ... } and the imports are inside try/catch. When the cloud plugin is absent (OSS), both blocks short-circuit and the UI is identical to before. The route addition lives inside the existing ReviewLayout && ManualReviewPage block so it can never override an existing route.

Database Migrations

  • None.

Env Config

  • None.

Relevant Docs

  • N/A

Related Issues or PRs

  • UN-3386
  • Companion (plugin implementation): Zipstack/unstract-cloud#1464 — merge this OSS PR first or together so the cloud plugin has its host hooks.
  • Depends on (server-side, separate work): UN-2128 for per-field tool/prompt attribution on HITLChangeLog rows.

Dependencies Versions

  • None.

Notes on Testing

  • OSS-only build (no cloud plugins): start npm start, open Prompt Studio — no indicator button, no console errors, no broken routes.
  • Hit /<orgName>/review/readonly/anything in OSS — should fall through (route only registers when plugin loads).
  • With cloud plugin synced into frontend/src/plugins/prompt-change-indicator/: indicator renders next to each prompt header and the readonly route works.

Screenshots

N/A

Checklist

I have read and understood the Contribution Guidelines.

🤖 Generated with Claude Code

Wires up the host-side hooks for the prompt-change-indicator plugin
(implementation lives in unstract-cloud): a dynamic-import slot in
the prompt card Header for the indicator button, and a route at
:orgName/review/readonly/:documentId for the read-only audit view.
Both gates fall through gracefully when the plugin is absent (OSS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52f4301c-2ca8-4971-b8d6-032631b71048

📥 Commits

Reviewing files that changed from the base of the PR and between 3d02972 and 8265e38.

📒 Files selected for processing (2)
  • frontend/src/components/custom-tools/prompt-card/Header.jsx
  • frontend/src/routes/useMainAppRoutes.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/custom-tools/prompt-card/Header.jsx
  • frontend/src/routes/useMainAppRoutes.js

Summary by CodeRabbit

  • New Features

    • Added a read-only review page for prompts accessible via a new route.
    • Integrated an optional prompt change indicator that appears when available.
  • Improvements

    • Improved handling for optional components to prevent build interruptions.
    • Added safeguards and warnings to avoid silent non-registration of review pages.

Walkthrough

Header and routing now optionally load a prompt-change plugin via cloud-only dynamic imports: Header conditionally renders a PromptChangeIndicator, and the route tree conditionally registers a read-only review page under ReviewLayout when the plugin is available.

Changes

Cohort / File(s) Summary
Optional Plugin UI Integration
frontend/src/components/custom-tools/prompt-card/Header.jsx
Performs a cloud-only dynamic import of PromptChangeIndicator, swallows missing-plugin errors so build continues, and conditionally renders the indicator passing promptDetails and details (as toolDetails) alongside the expand card button.
Dynamic Route Registration
frontend/src/routes/useMainAppRoutes.js
Adds lazy/dynamic import for a prompt-change-indicator ReadOnlyReviewPage. Handles import failures by distinguishing expected "module missing" vs unexpected errors, warns if the readonly component exists without ReviewLayout, and conditionally registers review/readonly/:documentId under the ReviewLayout subtree when present.

Sequence Diagram(s)

sequenceDiagram
  participant AppRouter as App Router
  participant Importer as Dynamic Importer
  participant Plugin as ReadOnlyReviewPlugin
  participant ReviewLayout as ReviewLayout
  AppRouter->>Importer: attempt import "prompt-change-indicator"
  alt import succeeds
    Importer->>Plugin: load module
    Plugin-->>Importer: module exported
    Importer-->>AppRouter: register route `review/readonly/:documentId`
    AppRouter->>ReviewLayout: mount nested route when visited
    ReviewLayout->>Plugin: render ReadOnlyReviewPage
  else module missing
    Importer-->>AppRouter: swallow missing-plugin error (no route registered)
  else unexpected error
    Importer-->>AppRouter: console.error and do not register route
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main feature: adding a plugin slot for a Prompt Studio HITL change indicator, with the ticket reference providing context.
Description check ✅ Passed The description comprehensively covers all required template sections: What, Why, How, backward compatibility assessment, database/env changes, related issues, testing notes, and the contribution checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch UN-3386-prompt-studio-hitl-feedback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR exposes two plugin integration points in the OSS host for a cloud-only HITL change-indicator feature: a PromptChangeIndicator slot in the prompt-card Header and a ReadOnlyReviewPage route under the existing ReviewLayout group. Both additions are gated behind try/catch dynamic imports and conditional rendering, so OSS builds are unaffected.

  • Header.jsx: dynamically imports PromptChangeIndicator and renders it (passing promptDetails and details as toolDetails) between ExpandCardBtn and PromptRunBtnSps; falls back to nothing when the plugin is absent.
  • useMainAppRoutes.js: adds a ReadOnlyReviewPage import with improved error surfacing (distinguishes MODULE_NOT_FOUND from real failures), a console.warn guard when the plugin loads without ReviewLayout, and a review/readonly/:documentId route nested inside the existing ReviewLayout && ManualReviewPage block.

Confidence Score: 5/5

Safe to merge — both integration points are fully guarded by try/catch and conditional rendering, leaving OSS builds completely unaffected.

All new code paths are unreachable in OSS builds. The route addition is nested inside the existing ReviewLayout/ManualReviewPage guard and cannot override any existing route. The only notable gap is that the PromptChangeIndicator import silently swallows all errors while the paired ReadOnlyReviewPage import has better error surfacing — but this is consistent with other plugin imports in Header.jsx and does not affect correctness.

No files require special attention; both changed files follow existing codebase conventions and the new code is well-isolated.

Important Files Changed

Filename Overview
frontend/src/components/custom-tools/prompt-card/Header.jsx Adds a dynamic-import plugin slot for PromptChangeIndicator, rendered between ExpandCardBtn and PromptRunBtnSps. Error handling in the catch block is silent (consistent with other plugins in this file but less thorough than the paired ReadOnlyReviewPage import).
frontend/src/routes/useMainAppRoutes.js Adds ReadOnlyReviewPage dynamic import with proper MODULE_NOT_FOUND detection and console.error for unexpected failures, a console.warn guard when the plugin loads without ReviewLayout, and the route nested correctly inside the existing ReviewLayout/ManualReviewPage block.

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
frontend/src/components/custom-tools/prompt-card/Header.jsx:44-52
**Silent catch swallows real plugin errors**

The `PromptChangeIndicator` import catches every error silently, including syntax errors and runtime failures inside the plugin. The companion `ReadOnlyReviewPage` import in `useMainAppRoutes.js` was improved (after a prior review round) to distinguish `MODULE_NOT_FOUND` (expected in OSS) from real failures and emit a `console.error` for the latter. If the cloud plugin ships with a broken `PromptChangeIndicator.jsx`, the button will simply never appear and there will be no console signal — making the failure invisible to the developer.

Reviews (4): Last reviewed commit: "Merge branch 'main' into UN-3386-prompt-..." | Re-trigger Greptile

Comment thread frontend/src/routes/useMainAppRoutes.js
@vishnuszipstack vishnuszipstack marked this pull request as draft April 27, 2026 09:00
vishnuszipstack and others added 2 commits April 27, 2026 14:34
Addresses review feedback: the readonly route nests inside ReviewLayout
(manual-review plugin), so a deployment that ships prompt-change-indicator
without manual-review would silently fail to register the route. Log a
console.warn in that case to make the misconfiguration discoverable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bare catch in the prompt-change-indicator dynamic import was swallowing
syntax/runtime errors in the plugin file alongside the expected
"plugin missing in OSS" case. Detect the missing-module messages
explicitly and console.error anything else so a broken cloud plugin
no longer disables the readonly route silently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vishnuszipstack vishnuszipstack marked this pull request as ready for review April 27, 2026 09:26
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
frontend/src/routes/useMainAppRoutes.js (1)

115-136: Module-missing heuristic risks false positives and Header.jsx has inconsistent error handling.

The "Failed to fetch dynamically imported module" message is emitted by Vite for both genuinely missing modules and transitive dependency failures (e.g., chunk 404, network blips, sub-import typos). This means the current check silently swallows errors that should be surfaced — the exact failure mode the improved error handling was meant to prevent. Consider tightening the check to include the plugin path substring, or rely solely on err?.code === "MODULE_NOT_FOUND".

Additionally, frontend/src/components/custom-tools/prompt-card/Header.jsx (lines 42–49) uses a bare catch {} for the same prompt-change-indicator plugin. This creates an inconsistency: a broken cloud build surfaces an error here but silently disappears in the header, contradicting the PR goal of failing loudly for broken plugins.

🔧 Optional: tighten the missing-module check
   const msg = err?.message || "";
   const isModuleMissing =
     err?.code === "MODULE_NOT_FOUND" ||
-    msg.includes("Failed to fetch dynamically imported module") ||
-    msg.includes("Cannot find module");
+    msg.includes("Cannot find module") ||
+    (msg.includes("Failed to fetch dynamically imported module") &&
+      msg.includes("prompt-change-indicator/ReadOnlyReviewPage"));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/routes/useMainAppRoutes.js` around lines 115 - 136, The
dynamic-import error handling in useMainAppRoutes.js around the
ReadOnlyReviewPage import is too permissive and can hide runtime or transitive
dependency failures; tighten the missing-module heuristic by checking err?.code
=== "MODULE_NOT_FOUND" or by additionally verifying the error message contains
the plugin path substring ("prompt-change-indicator/ReadOnlyReviewPage") before
treating it as a harmless missing-module case, and log/throw all other errors;
also make Header.jsx's bare catch (in the prompt-change-indicator import there)
consistent by replacing the empty catch with the same tightened heuristic and
error-logging behavior so unexpected plugin failures are surfaced uniformly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/src/routes/useMainAppRoutes.js`:
- Around line 115-136: The dynamic-import error handling in useMainAppRoutes.js
around the ReadOnlyReviewPage import is too permissive and can hide runtime or
transitive dependency failures; tighten the missing-module heuristic by checking
err?.code === "MODULE_NOT_FOUND" or by additionally verifying the error message
contains the plugin path substring
("prompt-change-indicator/ReadOnlyReviewPage") before treating it as a harmless
missing-module case, and log/throw all other errors; also make Header.jsx's bare
catch (in the prompt-change-indicator import there) consistent by replacing the
empty catch with the same tightened heuristic and error-logging behavior so
unexpected plugin failures are surfaced uniformly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f482928-5b1e-48a0-a0d5-a2d4b16c27b8

📥 Commits

Reviewing files that changed from the base of the PR and between 200b2b5 and 3d02972.

📒 Files selected for processing (1)
  • frontend/src/routes/useMainAppRoutes.js

vishnuszipstack and others added 2 commits May 19, 2026 11:11
Resolve conflict in Header.jsx by keeping both plugin import blocks:
the prompt-change-indicator plugin (this branch) and the lookup-studio
plugins (main).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Frontend Lint Report (Biome)

All checks passed! No linting or formatting issues found.

@sonarqubecloud
Copy link
Copy Markdown

@vishnuszipstack vishnuszipstack merged commit ff5d121 into main May 19, 2026
8 checks passed
@vishnuszipstack vishnuszipstack deleted the UN-3386-prompt-studio-hitl-feedback branch May 19, 2026 09:09
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.

4 participants