[PR #316] [MERGED] refactor: v1 raw file response + embeddings helpers #331

Closed
opened 2026-02-15 17:16:57 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/316
Author: @steipete
Created: 2/14/2026
Status: Merged
Merged: 2/14/2026
Merged by: @steipete

Base: mainHead: refactor/followups-4


📝 Commits (1)

  • 14de4cb refactor: dedupe v1 file response + unify embedding patches

📊 Changes

4 files changed (+124 additions, -122 deletions)

View changed files

📝 convex/httpApiV1/shared.ts (+41 -0)
📝 convex/httpApiV1/skillsV1.ts (+9 -27)
📝 convex/httpApiV1/soulsV1.ts (+9 -24)
📝 convex/skills.ts (+65 -71)

📄 Description

Small followup refactors.

  • httpApiV1: centralize safe raw text-file response headers/CSP in shared helper
  • skills: centralize skillEmbeddings visibility loops (soft-delete, ban/unban restore, approvals, latest tag)

Gate:

  • bun run lint
  • bun run build
  • bun run test

Greptile Overview

Greptile Summary

This PR successfully extracts duplicate code into reusable helpers, improving maintainability without changing functionality.

HTTP API Changes:

  • Centralized safe text-file response headers and CSP (Content Security Policy) into safeTextFileResponse() helper in convex/httpApiV1/shared.ts:18
  • Applied to both skills and souls file serving endpoints, eliminating ~20 lines of duplicated header logic in each handler

Skills Embedding Updates:

  • Consolidated 5 separate patterns of updating skillEmbeddings visibility into 4 focused helper functions:
    • listSkillEmbeddingsForSkill() - query helper
    • setSkillEmbeddingsSoftDeleted() - handles soft delete/restore flow
    • setSkillEmbeddingsLatestVersion() - updates latest tag visibility
    • setSkillEmbeddingsApproved() - updates approval visibility
  • Removes ~60 lines of repetitive embedding query/update loops across 6 call sites
  • Maintains exact same visibility logic via embeddingVisibilityFor() helper

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a pure refactoring that extracts duplicate code into helpers
  • The changes are mechanical refactorings that consolidate duplicate code patterns without modifying logic. All security headers, CSP policies, and embedding visibility rules remain identical. The new helpers make the code more maintainable and reduce the risk of divergence between similar operations.
  • No files require special attention

Last reviewed commit: 14de4cb


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/316 **Author:** [@steipete](https://github.com/steipete) **Created:** 2/14/2026 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@steipete](https://github.com/steipete) **Base:** `main` ← **Head:** `refactor/followups-4` --- ### 📝 Commits (1) - [`14de4cb`](https://github.com/openclaw/clawhub/commit/14de4cb164ad74a8baaf0aa6348c040bdabed114) refactor: dedupe v1 file response + unify embedding patches ### 📊 Changes **4 files changed** (+124 additions, -122 deletions) <details> <summary>View changed files</summary> 📝 `convex/httpApiV1/shared.ts` (+41 -0) 📝 `convex/httpApiV1/skillsV1.ts` (+9 -27) 📝 `convex/httpApiV1/soulsV1.ts` (+9 -24) 📝 `convex/skills.ts` (+65 -71) </details> ### 📄 Description Small followup refactors. - httpApiV1: centralize safe raw text-file response headers/CSP in shared helper - skills: centralize skillEmbeddings visibility loops (soft-delete, ban/unban restore, approvals, latest tag) Gate: - bun run lint - bun run build - bun run test <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR successfully extracts duplicate code into reusable helpers, improving maintainability without changing functionality. **HTTP API Changes:** - Centralized safe text-file response headers and CSP (Content Security Policy) into `safeTextFileResponse()` helper in `convex/httpApiV1/shared.ts:18` - Applied to both skills and souls file serving endpoints, eliminating ~20 lines of duplicated header logic in each handler **Skills Embedding Updates:** - Consolidated 5 separate patterns of updating `skillEmbeddings` visibility into 4 focused helper functions: - `listSkillEmbeddingsForSkill()` - query helper - `setSkillEmbeddingsSoftDeleted()` - handles soft delete/restore flow - `setSkillEmbeddingsLatestVersion()` - updates latest tag visibility - `setSkillEmbeddingsApproved()` - updates approval visibility - Removes ~60 lines of repetitive embedding query/update loops across 6 call sites - Maintains exact same visibility logic via `embeddingVisibilityFor()` helper <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with no risk - it's a pure refactoring that extracts duplicate code into helpers - The changes are mechanical refactorings that consolidate duplicate code patterns without modifying logic. All security headers, CSP policies, and embedding visibility rules remain identical. The new helpers make the code more maintainable and reduce the risk of divergence between similar operations. - No files require special attention <sub>Last reviewed commit: 14de4cb</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:57 -05:00
yindo closed this issue 2026-02-15 17:16:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#331