发布

  • [OPIK-4035] [BE] [FE] [SDK] Remove thread status requirement for feed… (#4912)

    frostbyte_neo 发布于 2026-02-04 20:38:08 +00:00

    • [OPIK-4035] [BE] [FE] [SDK] Remove thread status requirement for feedback scores

    Remove the requirement for threads to be inactive before adding feedback scores.
    This simplifies the user experience by allowing feedback, comments, and tags to
    be added to threads at any time.

    Backend changes:

    • Remove thread status validation from feedback score creation
    • Add deleteAllThreadScores() method to delete all score types (UI, SDK, online)
    • Update ThreadsReopened event to delete all scores when new traces are added
    • Decouple ThreadsReopened event from inactive status check

    Frontend changes:

    • Hide thread status display from UI (ThreadDetailsPanel, ThreadsTab, QueueItemsTab)
    • Remove status-based restrictions on feedback score editing
    • Remove status filters from thread tables
    • Update terminology from "thread timeout" to "online scoring cooling period"
    • Remove SetInactiveConfirmDialog component

    SDK changes:

    • Deprecate close_thread() method with warning
    • Keep SDK evaluation filtering for inactive threads only

    Documentation changes:

    • Update docs to reflect that feedback can be added anytime
    • Clarify that cooling period only applies to online evaluation
    • Remove references to manual thread status management

    Note: Thread status (active/inactive) is still maintained internally for the
    online scoring cooling period mechanism, but is no longer exposed to users
    for feedback score management.

    • Revision 2: Improve error logging structure in TraceThreadListener

    Add workspace, project, and thread IDs to error log message for better
    searchability and debugging. Combine redundant log.info and log.error
    calls into a single structured log.error call with the exception as the
    final parameter.

    This addresses PR feedback to ensure error logs contain full context
    (workspace ID, project ID, thread model IDs) in a single structured
    entry, making it easier to search and debug in log aggregation systems.

    • Revision 3: Remove unused isThread parameter from validateCurrentItem

    Remove the unused isThread parameter from validateCurrentItem function
    and its call site. This parameter became unused after removing thread
    status validation logic that previously checked if threads were active
    or inactive before allowing feedback scores.

    This fixes the ESLint error: '@typescript-eslint/no-unused-vars'

    • Revision 4: Update thread feedback score tests to reflect status validation removal

    Update backend tests to align with the removal of thread status validation for
    feedback scoring. Tests now verify that:

    1. Active threads can be scored successfully (no longer return 409 conflict)
    2. Non-existent threads create thread ID mappings on-demand to handle race
      conditions where traces are logged and immediately scored
    3. All scores (UI, SDK, ONLINE_SCORING) are deleted when threads are reopened,
      not just manual scores

    Changes:

    • scoreBatchOfThreads_withThreadsAreOpen_thenScoresArePersisted: Expect 204
      success instead of 409 conflict when scoring active threads
    • scoreBatchOfThreads_withThreadsDontExist_thenThreadsCreatedAndScoresPersisted:
      Renamed and updated to verify thread ID mapping creation and score persistence
    • whenThreadIsClosedWithMixedScores_andReopened_thenAllScoresAreDeleted:
      Renamed and updated to verify all score types are deleted, not just manual
    • Remove unused assertOpenThreadScoreConflict helper method

    All tests now pass successfully.

    • Revision 5: Address PR review comments - fix typo and remove unused components

    Address feedback from andriidudar's review:

    • Fix typo in test display name: "dont" → "don't"
    • Remove unused components: ThreadStatusCell, ThreadStatusTag, SetInactiveConfirmDialog
    • Remove unnecessary comment in SMEFlowContext about thread status validation
    • Keep ThreadStatus enum as it's still used for filtering in dashboard, automation rules, and metrics

    All tests pass and linter checks succeed.

    • Revision 6: Rename "Online scoring cooling period" to "Thread online scoring rule cooldown period"

    Update UI and documentation to clarify that the cooldown period only affects
    thread-level online scoring rules, not trace-level rules or manual feedback.

    Frontend changes:

    • Update config table label to "Thread online scoring rule cooldown period"
    • Update dialog title, description, toast messages, and button text
    • Change form label from "Thread Timeout" to "Cooldown period"

    Documentation changes:

    • Rename section headers to use "Thread Online Scoring Rule Cooldown Period"
    • Add new section documenting behavior when traces are added to existing threads:
      • All previous feedback scores are deleted
      • Cooldown timer restarts from last activity
      • Online evaluation re-runs after cooldown expires
    • Remove deprecated close_trace_thread reference
    • Update filter examples to remove status="inactive" (hidden from users)
    • Clarify SDK evaluation only evaluates inactive threads vs manual feedback
    • Use consistent "cooldown" terminology throughout (instead of "cooling")

    All linter checks pass.

    • Revision 7: Remove thread status filters from frontend UI

    Remove all remaining thread status (Active/Inactive) filter options from
    the frontend to complete the decoupling of thread status from user-facing
    features. Thread status is now purely an internal implementation detail
    used only for online evaluation cooldown timing.

    Changes:

    • Remove status filter from dashboard widget filters
    • Remove status filter from automation rule filters
    • Remove status filter from thread metrics section
    • Delete unused useThreadCloseStatusMutation hook
    • Clean up unused variables and fix linter warnings

    Thread status still exists in the data model (ThreadStatus enum and
    Thread.status field) as the backend API continues to return it, but
    users can no longer see or interact with it anywhere in the UI.

    • Revision 8: Remove unused deleteThreadManualScores and improve ThreadsReopened docs
    • Remove deleteThreadManualScores() from FeedbackScoreDAO and FeedbackScoreService
      (dead code after switching to deleteAllThreadScores)
    • Improve Javadoc for onThreadsReopened() to clarify the two trigger scenarios
    • Add clarifying comment in TraceThreadService explaining the "Reopened" event name
    • Revision 9: Rename threadModelId to threadModelIds for clarity

    Rename singular parameter name to plural to match Set type in
    deleteAllThreadScores() method signature and implementation.

    下载附件