feat(desktop): setup/teardown scripts editor for v2 projects

Merged
KI
6mo ago
+1877-27

Summary

  • Brings back the project-settings UI for editing the .superset/config.json setup and teardown scripts for v2 projects (the editor existed for v1 only).
  • Generalizes the config.getConfigContent / updateConfig tRPC routes to accept either { projectId } (v1 local-db lookup) or { mainRepoPath } (v2 host project), so a single ScriptsEditor works in both surfaces.
  • Reworks editor behavior: save only on blur, trim only on blur (so pressing Enter during editing no longer trims trailing whitespace/newlines), and skip the network call when the trimmed value matches the last saved snapshot.
  • Refreshes the section UI to match the v2 settings style — shared <Textarea>, tighter heading + description pair, smaller h-7 action buttons, subtler drag-import overlay.
  • Run tab is hidden for now while v2 host-side runner support is still pending; existing run values are preserved through load/save.

Test plan

  • Open a v2 project's settings → "Scripts" section appears between Appearance and Delete; edits to Setup/Teardown persist to <repoPath>/.superset/config.json.
  • Open a v1 project's settings → editor still works exactly as before; existing config files are untouched.
  • Type into a textarea, press Enter to add a newline at the end → blur the textarea → newline is trimmed and a save fires once.
  • Type a change and immediately switch tabs → the change saves on blur (not while typing).
  • Type and revert to original → blur fires no network request.
  • Drag a .sh file onto a textarea → contents replace the value; blur saves it.
  • Open a v2 project whose config already has a non-empty run array → run value is preserved on subsequent saves of setup/teardown (not zeroed out by the hidden tab).

Summary by CodeRabbit

  • Refactor

    • Scripts editor redesigned into a unified view with focus-aware syncing, save-on-blur, simplified tabs and improved file-import UX.
  • New Features

    • Two editor variants supported (local and host-service); settings surfaces render the appropriate editor.
    • Dismissible "Setup scripts" sidebar card that links to project settings.
    • Backend config API to read/update project script configuration on disk.
  • Chores

    • Persistent store added to track dismissed setup cards.