Skip to content

Feature/telemetry feedback rating clean#153

Merged
wherka-ama merged 21 commits intoAmadeusITGroup:feature/telemetry-feedback-rating-cleanfrom
wherka-ama:feature/telemetry-feedback-rating-clean
Feb 4, 2026
Merged

Feature/telemetry feedback rating clean#153
wherka-ama merged 21 commits intoAmadeusITGroup:feature/telemetry-feedback-rating-cleanfrom
wherka-ama:feature/telemetry-feedback-rating-clean

Conversation

@wherka-ama
Copy link
Member

@wherka-ama wherka-ama commented Feb 4, 2026

Description

This PR introduces a comprehensive engagement system for the Prompt Registry, enabling users to rate bundles and submit feedback. The system provides a complete UI integration in both the marketplace and registry explorer.

The engagement system includes:

  • 5-star rating system with optional feedback comments
  • Rating computation via GitHub Actions workflow
  • Feedback submission with optional GitHub issue redirect
  • Hub-level configuration for engagement settings
  • Complete UI integration in marketplace and tree view

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 📝 Documentation update
  • 🧪 Test coverage improvement
  • 🔧 Configuration/build changes

Related Issues

Relates to feedback system refactoring and community engagement features.
#98 (#20, #25, #80 )

Changes Made

Core Engagement System

Type Definitions (src/types/engagement.ts)

  • Add telemetry types for event tracking
  • Add rating types with Wilson score and Bayesian smoothing support
  • Add feedback types with star ratings (1-5)
  • Add backend configuration types (File, GitHub Discussions)
  • Add privacy settings types
  • Add hub engagement configuration types

Storage Layer (src/storage/EngagementStorage.ts)

  • Implement JSON file-based persistence with atomic writes
  • Support telemetry events, ratings, and feedback storage
  • Add query methods with filtering support
  • Store data in extension's global storage directory

Rating Algorithms (src/utils/ratingAlgorithms.ts)

  • Wilson score lower bound for binary ratings (up/down votes)
  • Bayesian smoothing for positive-only ratings
  • Score-to-stars and stars-to-score conversion utilities
  • Aggregate score calculation for collections

Backend Implementations

Backend Interface (src/services/engagement/IEngagementBackend.ts)

  • Define backend contract for engagement operations
  • BaseEngagementBackend abstract class with common functionality

File Backend (src/services/engagement/backends/FileBackend.ts)

  • Local file-based storage implementation
  • Support for telemetry, ratings, and feedback operations

GitHub Discussions Backend (src/services/engagement/backends/GitHubDiscussionsBackend.ts)

  • Post feedback as discussion comments with star ratings
  • Load collection mappings from collections.yaml
  • Use VS Code GitHub authentication provider

Services

EngagementService (src/services/engagement/EngagementService.ts)

  • Singleton facade for all engagement operations
  • Hub-specific backend routing
  • Event emission for rating and feedback submissions
  • Privacy settings enforcement

RatingService (src/services/engagement/RatingService.ts)

  • Fetch ratings from hub's ratings.json
  • Support rating lookup by bundle ID with source prefix matching
  • Parse and validate ratings.json format

RatingCache (src/services/engagement/RatingCache.ts)

  • In-memory caching with TTL
  • Automatic cache invalidation
  • Source ID mapping to handle hub-prefixed source IDs

FeedbackService (src/services/engagement/FeedbackService.ts)

  • Feedback submission operations
  • Integration with engagement backends

FeedbackCache (src/services/engagement/FeedbackCache.ts)

  • In-memory feedback caching
  • Query and filtering support

Commands

FeedbackCommands (src/commands/FeedbackCommands.ts)

  • Unified feedback dialog with star rating (1-5) and optional comment
  • Issue redirect to source repository
  • Extract GitHub org/repo for proper issue URL construction
  • Commands: submitFeedback, openIssueTracker

UI Integration

Marketplace (src/ui/MarketplaceViewProvider.ts, src/ui/webview/marketplace/*)

  • Externalize webview assets (HTML, CSS, JS)
  • Add rating display to bundle tiles
  • Show star rating, vote count, and confidence level
  • IIFE pattern for JavaScript to comply with CSP
  • Data-action attributes instead of inline event handlers

Registry Tree View (src/ui/RegistryTreeProvider.ts)

  • Add rating display to tree view items
  • Integrate RatingCache for fetching cached ratings
  • Context menu entries for engagement commands

Bundle Details (src/ui/webview/bundleDetails/*)

  • Externalize webview assets
  • CSP compliance with nonce-based script loading

Hub Integration

Hub Manager (src/services/HubManager.ts)

  • Add registerHubEngagement() for backend initialization
  • Add initializeEngagementBackends() for activation-time initialization
  • Support GitHub Discussions backend configuration

Hub Schema (schemas/hub-config.schema.json, src/types/hub.ts)

  • Add engagement configuration schema
  • Support backend configuration (file, github-discussions)
  • Validation for engagement settings

Extension Integration

Extension Activation (src/extension.ts)

  • Initialize EngagementService on activation
  • Register VoteCommands and FeedbackCommands
  • Initialize hub engagement backends

Package Configuration (package.json)

  • Register engagement commands
  • Add context menu entries for voting and feedback
  • Add CopyWebpackPlugin dependency for webview assets

Rating Computation Package

@prompt-registry/collection-scripts (lib/)

  • Add compute-ratings CLI tool for rating computation
  • Add setup-discussions CLI tool for GitHub Discussion creation
  • Parse star ratings from feedback comments (1-5 ⭐)
  • Support legacy thumbs up/down reactions for backward compatibility
  • Wilson score algorithm for robust ranking
  • GitHub Actions workflow template for automated rating updates
  • Published as npm package: @prompt-registry/collection-scripts@1.0.3

Documentation

User Guide (docs/user-guide/engagement.md)

  • Comprehensive guide for engagement features
  • Feedback submission flow with star ratings
  • Hub maintainer setup guide for GitHub Discussions
  • Rating computation workflow documentation
  • Privacy considerations and troubleshooting

Reference Documentation

  • Update commands reference (docs/reference/commands.md)
  • Update hub schema documentation (docs/reference/hub-schema.md)
  • Document webview architecture and CSP compliance (docs/contributor-guide/architecture/ui-components.md)

Workflow Asset (docs/assets/compute-ratings.yml)

  • Downloadable GitHub Actions workflow for rating computation
  • Intended for hub repositories, not the extension itself

Package Documentation (lib/README.md)

  • Document engagement tools (setup-discussions, compute-ratings)
  • Update to reflect 5-star rating system
  • Add npx usage examples with --package flag

Build Configuration

Webpack (webpack.config.js)

  • Add CopyWebpackPlugin for webview asset copying
  • Configure asset paths for marketplace and bundle details

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All existing tests pass

Test Files Added

Engagement Services (1,900+ lines of tests)

  • test/services/engagement/EngagementService.test.ts - Service facade tests
  • test/services/engagement/RatingService.test.ts - Rating service tests
  • test/services/engagement/RatingCache.test.ts - Cache tests
  • test/services/engagement/FeedbackCache.test.ts - Feedback cache tests

Backend Tests (700+ lines)

  • test/services/engagement/backends/FileBackend.test.ts - File backend tests
  • test/services/engagement/backends/GitHubDiscussionsBackend.test.ts - GitHub backend tests with nock HTTP mocking

Command Tests (200+ lines)

  • test/commands/FeedbackCommands.test.ts - Feedback command tests

Storage Tests (670+ lines)

  • test/storage/EngagementStorage.test.ts - Storage layer tests

Utility Tests (700+ lines)

  • test/utils/ratingAlgorithms.test.ts - Rating algorithm tests
  • lib/test/compute-ratings.test.ts - Rating computation tests

Type Validation Tests (420+ lines)

  • test/types/hub-engagement-validation.test.ts - Hub engagement config validation

Total Test Coverage: 4,800+ lines of comprehensive tests

Manual Testing Steps

  1. Install and activate a bundle from marketplace

    • Verify rating display appears on bundle tiles
    • Verify rating display appears in tree view
  2. Submit feedback with star rating

    • Open command palette: "Prompt Registry: Rate & Feedback"
    • Select a bundle
    • Choose star rating (1-5)
    • Optionally add comment
    • Verify feedback is submitted
  3. Hub engagement configuration

    • Import a hub with engagement configuration
    • Verify engagement backend is initialized
    • Verify ratings are fetched from hub's ratings.json
  4. Rating computation (for hub maintainers)

    • Run npx --package @prompt-registry/collection-scripts setup-discussions
    • Run npx --package @prompt-registry/collection-scripts compute-ratings
    • Verify ratings.json is generated

Tested On

  • Linux
  • VS Code Stable

Screenshots

image image image image image image image

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Documentation

  • README.md updated (docs/README.md - added engagement.md link)
  • JSDoc comments added/updated
  • Comprehensive user guide added (docs/user-guide/engagement.md)
  • Reference documentation updated (commands.md, hub-schema.md)
  • Architecture documentation updated (ui-components.md)
  • Package documentation updated (lib/README.md)

Additional Notes

Published Package

The rating computation tools have been published to npm:

  • Package: @prompt-registry/collection-scripts@1.0.3
  • License: Apache-2.0 (aligned with main repository)
  • Includes: compute-ratings, setup-discussions CLI tools

Breaking Changes

None. This is a purely additive feature that does not affect existing functionality.

Migration Notes

For hub maintainers who want to enable community engagement:

  1. Enable GitHub Discussions on your engagement repository
  2. Run setup-discussions to create discussions for bundles
  3. Add the GitHub Actions workflow from docs/assets/compute-ratings.yml
  4. Configure engagement in your hub.yaml

Key Implementation Fixes

During development, several critical issues were identified and resolved:

  1. Rating Count Field: Added rating_count field to track actual star ratings separately from legacy reaction-based votes (up/down). This ensures the 5-star rating system correctly reflects the number of star ratings rather than reaction counts.

  2. Source ID Mapping: Fixed sourceId mismatch where RatingCache stored ratings using source_id from ratings.json (e.g., "awesome-copilot-official"), but the UI looked them up using hub-prefixed source IDs (e.g., "hub-awesome-copilot-hub-099578-awesome-copilot-official"). Implemented source ID mapping in RatingCache.refreshFromHub() to ensure ratings are stored with the correct source IDs that match UI lookups.

  3. Rating Computation Algorithm: Corrected the star rating computation to properly parse 1-5 star ratings from feedback comments and calculate accurate averages with proper confidence levels.

Architecture Decisions

  1. Backend Abstraction: Abstracted backend interface allows for file-based (local), GitHub Discussions (community), or future API-based backends
  2. 5-Star Rating System: Uses 5-star ratings for granular feedback
  3. Pre-computed Ratings: Ratings are computed via GitHub Actions and served as static JSON for performance
  4. CSP Compliance: Externalized webview assets to comply with Content Security Policy
  5. Singleton Services: EngagementService, RatingService use singleton pattern for consistent state

Reviewer Guidelines

Please pay special attention to:

  • Backend abstraction: Verify the IEngagementBackend interface is flexible enough for future implementations
  • Error handling: Check error handling in GitHub API calls and file operations
  • Test coverage: Ensure all critical paths are covered by tests
  • Documentation accuracy: Verify documentation matches implementation (note: voting commands were removed as unused)
  • CSP compliance: Check that webview assets comply with Content Security Policy
  • Rating algorithm correctness: Verify Wilson score and Bayesian smoothing implementations
  • Hub configuration validation: Ensure engagement config validation is robust

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.

Waldek Herka added 21 commits February 4, 2026 10:31
- Add telemetry types (TelemetryEvent, TelemetryFilter, TelemetryEventType)
- Add rating types (Rating, RatingScore, RatingStats)
- Add feedback types (Feedback, EngagementResourceType)
- Add backend configuration types (FileBackendConfig, GitHubDiscussionsBackendConfig)
- Add privacy settings types (EngagementPrivacySettings)
- Add hub engagement configuration types (HubEngagementConfig)

These types form the foundation for the engagement system, supporting
telemetry tracking, user ratings, feedback collection, and multiple
backend implementations.
- Add Wilson score lower bound for binary ratings (up/down votes)
- Add Bayesian smoothing for positive-only ratings
- Add score-to-stars and stars-to-score conversion utilities
- Add aggregate score calculation for collections
- Add comprehensive tests for all algorithms

These algorithms provide robust ranking that handles small sample sizes
well, preventing items with few votes from dominating rankings.
- Add EngagementStorage class for persistent storage of engagement data
- Support telemetry events, ratings, and feedback storage
- Implement JSON file-based persistence with atomic writes
- Add query methods with filtering support
- Add comprehensive tests for all storage operations

This provides the persistence layer for the engagement system, storing
data in the extension's global storage directory.
- Add IEngagementBackend interface defining backend contract
- Add BaseEngagementBackend abstract class with common functionality
- Implement FileBackend for local file-based storage
- Support telemetry, ratings, and feedback operations
- Add comprehensive tests for FileBackend

The backend abstraction allows multiple implementations (file, GitHub
Discussions, API) while maintaining a consistent interface.
- Implement GitHubDiscussionsBackend for voting via GitHub reactions
- Support collection-level voting on discussions
- Support resource-level voting on comments
- Load collection mappings from collections.yaml URL
- Post feedback as discussion comments
- Use FileBackend for local telemetry/feedback storage
- Add comprehensive tests with nock HTTP mocking

This backend enables community engagement through GitHub Discussions,
using reactions for voting and comments for feedback.
- Implement singleton EngagementService as unified facade
- Support hub-specific backend routing
- Initialize default file backend on startup
- Register hub backends dynamically based on configuration
- Emit events for rating and feedback submissions
- Support privacy settings enforcement
- Add comprehensive tests for service operations

The EngagementService provides a single entry point for all engagement
operations, routing requests to the appropriate backend based on hub.
- Add VoteService for voting via GitHub Discussion reactions
- Support upvote (+1) and downvote (-1) on collections and resources
- Implement vote toggle and removal
- Add VoteCommands for VS Code command registration
- Use VS Code GitHub authentication provider
- Add comprehensive tests for voting operations

Users can now vote on collections directly from VS Code, with votes
synced to GitHub Discussions as reactions.
- Add RatingService for fetching ratings from hub's ratings.json
- Add RatingCache for in-memory caching with TTL
- Support rating lookup by bundle ID with source prefix matching
- Parse and validate ratings.json format
- Add comprehensive tests for rating operations

Ratings are pre-computed by GitHub Actions and served as static JSON,
enabling fast rating display without runtime computation.
- Add FeedbackService for feedback operations
- Add FeedbackCache for in-memory feedback caching
- Add FeedbackCommands with unified feedback dialog
- Implement star rating (1-5) with optional comment
- Support issue redirect to source repository
- Extract GitHub org/repo for proper issue URL construction
- Add comprehensive tests for feedback operations

Users can submit feedback with star ratings and optional comments,
with the option to open a GitHub issue for detailed bug reports.
- Add engagement configuration schema to hub-config.schema.json
- Add registerHubEngagement() to HubManager for backend initialization
- Add initializeEngagementBackends() for activation-time initialization
- Support GitHub Discussions backend configuration
- Add validation tests for engagement configuration

Hubs can now configure engagement backends, enabling automatic
registration of the appropriate backend when a hub is imported.
- Add rating display to marketplace bundle tiles
- Add rating display to tree view items
- Integrate RatingCache for fetching cached ratings
- Show star rating, vote count, and confidence level
- Update registry types for rating display support

Users can now see ratings directly in the marketplace and tree view,
helping them discover high-quality bundles.
- Add marketplace webview assets (HTML, CSS, JS) as separate files
- Add bundleDetails webview assets (HTML, CSS, JS) as separate files
- Use IIFE pattern for JavaScript to comply with CSP
- Use data-action attributes instead of inline event handlers
- Add CopyWebpackPlugin to webpack config for asset copying

Externalizing webview content improves maintainability, enables CSP
compliance, and simplifies debugging of webview code.
- Initialize EngagementService on extension activation
- Initialize engagement backends for all existing hubs
- Register FeedbackCommands and VoteCommands
- Add copy-webpack-plugin dependency for webview assets
- Add feedback and vote commands to package.json
- Update context menu entries for engagement commands

The extension now fully integrates the engagement system, initializing
all services and registering commands on activation.
- Add compute-ratings.ts for rating computation from GitHub Discussions
- Add setup-discussions.ts for creating discussions from collections
- Implement Wilson score and Bayesian smoothing algorithms
- Support star rating parsing from feedback comments
- Add user deduplication (last rating wins)
- Add CLI wrappers for direct script execution
- Add comprehensive tests for rating computation
- Configure as standalone npm package (@prompt-registry/lib)

This package runs in GitHub Actions to compute ratings from Discussion
reactions and feedback comments, outputting ratings.json for static hosting.
- Update compute-ratings description to mention star rating parsing from comments
- Update setup-discussions description to mention star ratings instead of reactions
- Add npx --package syntax to all engagement tool examples
- Note backward compatibility with legacy thumbs up/down reactions
- Add comprehensive user guide for engagement features
- Document feedback submission flow with star ratings
- Add hub maintainer setup guide for GitHub Discussions
- Add compute-ratings.yml workflow as downloadable asset
- Update hub schema documentation for engagement config
- Update commands reference for feedback and vote commands
- Document webview architecture and CSP compliance
- Fix ESLint errors in FeedbackCommands.ts regex patterns
- Update license from MIT to Apache-2.0 to match main repository
- Bump version to 1.0.3
- Remove VoteCommands.ts and VoteService.ts (not used in UI)
- Remove all voting command registrations from package.json
- Remove voting command imports from extension.ts
- Update documentation to focus on feedback-only engagement
- Update .gitignore to exclude working/analysis files

The voting functionality was implemented but never integrated into
the UI or used anywhere in the codebase. This cleanup removes the
unused code while keeping the core feedback and rating features.
- Remove legacy reaction-based fallback when no star ratings exist
- Collections with no ratings now show star_rating: 0 instead of 3.5
- Convert bin/compute-ratings.js to wrapper script calling dist/ code
- Fix wilson_score calculation to properly normalize 5-star ratings

Previously, when no star ratings were found, the system fell back
to the legacy reaction-based system which used bayesianSmoothing()
with a prior mean of 3.5. This caused collections with 0 ratings to
show a star_rating of 3.5, which is incorrect.

Now, collections with no ratings show 0, and only actual star ratings
from feedback comments are used for the rating computation.
- Add rating_count field to CollectionRating interface
- Track actual number of star ratings separately from reactions
- Update RatingService to use rating_count instead of up+down
- Fix issue where ratings with 0 reactions but >0 star ratings were hidden

Previously, totalVotes was calculated as up+down (reactions), which
caused bundles with star ratings but no reactions to show voteCount=0
and be hidden from the UI. Now we properly track the actual number of
star ratings in the rating_count field.
The RatingCache was storing ratings using source_id from ratings.json
(e.g., 'awesome-copilot-official'), but the UI was looking them up using
the full extension source ID (e.g., 'hub-awesome-copilot-hub-099578-awesome-copilot-official').

This caused all cache lookups to return undefined, resulting in 'No ratings yet'
being displayed even when ratings existed.

Fix by:
- Adding sourceIdMap parameter to RatingCache.refreshFromHub()
- Building source ID mapping in extension.ts when loading hub ratings
- Using mapped source IDs when populating the cache

This ensures ratings are stored with the correct source IDs that match
what the UI uses for lookups.
lib/ratings.json

# Spec working directories
.kiro/specs/*/IMPLEMENTATION_PLAN.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we actually commit our spec ? Was thinking a new way of working could be open the PR already after generating the specs so that we can review. (You already did that by presenting it to us beforehand which is great !)

WDYT ?

|-------|------|-------------|
| `enabled` | boolean | Enable engagement features for this hub |
| `backend` | object | Backend configuration for engagement data storage |
| `telemetry` | object | Telemetry configuration |
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should include the telemetry as part of the engagement (it would be more technical)

@wherka-ama wherka-ama changed the base branch from main to feature/telemetry-feedback-rating-clean February 4, 2026 15:08
@wherka-ama wherka-ama merged commit 9f90fb6 into AmadeusITGroup:feature/telemetry-feedback-rating-clean Feb 4, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Prompt Registry Feb 4, 2026
@gblanc-1a
Copy link
Contributor

Notes taken while discussing about remaining point to adress with @wherka-ama

Reactive rating with single workflow inside engagement repository

  • Single discussion will receive feedbacks from all client with enough details to be able to determine the target discussions ratingID (bundle-id + source url)
  • Workflow will then consume this discussion and dispatch in the other discussions that are bundle specific
    • Need a redesign of the current population script and pipelines as the hub
    • Naming convention of the discussion (organization + repo + bundle-id)

Telemetry

  • Telemetry could be reusing existing telemetry ecosystem from vscode
  • Telemetry settings should be outside of engagement section in it's own section

Bug

  • Sorting by rating is not working well right now (5 stars are not put at the front)
  • Clicking on the stars should properly display fast comments and rating
    • image

UX Improvements

  • Remove confidence factor (text in parenthesis) but keep number of vote
  • Only displays stars that would become the button that we can interact with without an additional button. If no vote display no vote present. Replace vscode input field for comment by a an HTML text field popping below
  • Separate link for report issue and request feature in the UI
  • Immediate feedback for the user when rating should compute client side the number based on already downloaded number for bundle + actual vote of the user
  • Consistent behavior between zero rating (No ratings yet) and zero star (should disappear)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants