release-notes.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { CURRENT_RELEASE } from "@/components/dialog-release-notes"
  2. const STORAGE_KEY = "opencode:last-seen-version"
  3. // ============================================================================
  4. // DEV MODE: Set this to true to always show the release notes modal on startup
  5. // Set to false for production behavior (only shows after updates)
  6. // ============================================================================
  7. const DEV_ALWAYS_SHOW_RELEASE_NOTES = true
  8. /**
  9. * Check if release notes should be shown
  10. * Returns true if:
  11. * - DEV_ALWAYS_SHOW_RELEASE_NOTES is true (for development)
  12. * - OR the current version is newer than the last seen version
  13. */
  14. export function shouldShowReleaseNotes(): boolean {
  15. if (DEV_ALWAYS_SHOW_RELEASE_NOTES) {
  16. console.log("[ReleaseNotes] DEV mode: always showing release notes")
  17. return true
  18. }
  19. const lastSeen = localStorage.getItem(STORAGE_KEY)
  20. if (!lastSeen) {
  21. // First time user - show release notes
  22. return true
  23. }
  24. // Compare versions - show if current is newer
  25. return CURRENT_RELEASE.version !== lastSeen
  26. }
  27. /**
  28. * Mark the current release notes as seen
  29. * Call this when the user closes the release notes modal
  30. */
  31. export function markReleaseNotesSeen(): void {
  32. localStorage.setItem(STORAGE_KEY, CURRENT_RELEASE.version)
  33. }
  34. /**
  35. * Get the current version
  36. */
  37. export function getCurrentVersion(): string {
  38. return CURRENT_RELEASE.version
  39. }
  40. /**
  41. * Reset the seen status (useful for testing)
  42. */
  43. export function resetReleaseNotesSeen(): void {
  44. localStorage.removeItem(STORAGE_KEY)
  45. }