|
| 1 | +--- |
| 2 | +phase: 16-web-verification-polish |
| 3 | +plan: 02 |
| 4 | +type: execute |
| 5 | +wave: 1 |
| 6 | +depends_on: [] |
| 7 | +files_modified: |
| 8 | + - viewer/src/main.ts |
| 9 | + - viewer/index.html |
| 10 | +autonomous: true |
| 11 | +gap_closure: true |
| 12 | + |
| 13 | +must_haves: |
| 14 | + truths: |
| 15 | + - "User can click Share button to copy view state URL to clipboard" |
| 16 | + - "Share URL includes layer visibility, zoom, and pan position" |
| 17 | + - "Keyboard shortcut Ctrl+Shift+S triggers share action on web" |
| 18 | + artifacts: |
| 19 | + - path: "viewer/src/main.ts" |
| 20 | + provides: "Share button event listener and handleShareView wiring" |
| 21 | + contains: "shareBtn.addEventListener" |
| 22 | + - path: "viewer/index.html" |
| 23 | + provides: "Share button element visible in toolbar" |
| 24 | + contains: 'id="share-btn"' |
| 25 | + key_links: |
| 26 | + - from: "viewer/src/main.ts" |
| 27 | + to: "viewer/src/url-state.ts" |
| 28 | + via: "encodeViewState call in handleShareView" |
| 29 | + pattern: "encodeViewState" |
| 30 | + - from: "viewer/index.html share-btn" |
| 31 | + to: "viewer/src/main.ts handleShareView" |
| 32 | + via: "click event listener" |
| 33 | + pattern: "shareBtn.*addEventListener" |
| 34 | +--- |
| 35 | + |
| 36 | +<objective> |
| 37 | +Enable the Share URL feature that was intentionally disabled pending design decision. |
| 38 | + |
| 39 | +Purpose: Close WEB-07 gap. The viewport-only share approach is the correct design decision - sharing full board state via URL is impractical (file content too large) and unnecessary (users can share files directly). URL sharing is for collaboration on specific views of a design. |
| 40 | +Output: Working Share button that copies viewport URL to clipboard. |
| 41 | +</objective> |
| 42 | + |
| 43 | +<context> |
| 44 | +@viewer/src/main.ts (lines 965-1005 - handleShareView and commented code) |
| 45 | +@viewer/src/url-state.ts |
| 46 | +@viewer/index.html (line 348 - share-btn element) |
| 47 | +@.planning/phases/13-web-deployment/13-VERIFICATION.md |
| 48 | +</context> |
| 49 | + |
| 50 | +<tasks> |
| 51 | + |
| 52 | +<task type="auto"> |
| 53 | + <name>Task 1: Enable Share button and wire event listener</name> |
| 54 | + <files>viewer/src/main.ts</files> |
| 55 | + <action> |
| 56 | + The handleShareView() function (lines 967-998) is already implemented correctly. |
| 57 | + The Share button HTML element exists in index.html (line 348). |
| 58 | + The issue is on lines 1001-1005 where the code is commented out. |
| 59 | + |
| 60 | + 1. Uncomment the shareBtn variable declaration (around line 165): |
| 61 | + Change: `// const shareBtn = document.getElementById('share-btn') as HTMLButtonElement;` |
| 62 | + To: `const shareBtn = document.getElementById('share-btn') as HTMLButtonElement;` |
| 63 | + |
| 64 | + 2. Uncomment and enable the Share button wiring (lines 1001-1005): |
| 65 | + ```typescript |
| 66 | + // Share button (web only) |
| 67 | + if (!isDesktop()) { |
| 68 | + shareBtn.classList.remove('hidden'); |
| 69 | + shareBtn.addEventListener('click', handleShareView); |
| 70 | + } |
| 71 | + ``` |
| 72 | + Remove the TODO comment on line 1002 - the design decision is made: viewport-only sharing. |
| 73 | + |
| 74 | + 3. The keyboard shortcut Ctrl+Shift+S is already wired (lines 1028-1032) and calls handleShareView(). |
| 75 | + Verify it works by checking this code exists and is not commented out. |
| 76 | + |
| 77 | + Note: Do NOT add file content to URL. Viewport-only sharing is the correct approach because: |
| 78 | + - URLs have practical length limits (~2000 chars) |
| 79 | + - File content can be megabytes |
| 80 | + - Users can share files via other means (email, cloud storage) |
| 81 | + - URL sharing is for "look at this specific view" collaboration |
| 82 | + </action> |
| 83 | + <verify>`npx tsc --noEmit` passes. Search for "shareBtn.classList.remove" in main.ts to confirm uncommented.</verify> |
| 84 | + <done>Share button visible on web, click copies URL with viewport state to clipboard</done> |
| 85 | +</task> |
| 86 | + |
| 87 | +<task type="auto"> |
| 88 | + <name>Task 2: Remove 'hidden' class from Share button in HTML</name> |
| 89 | + <files>viewer/index.html</files> |
| 90 | + <action> |
| 91 | + The Share button in index.html (line 348) has class="hidden": |
| 92 | + ```html |
| 93 | + <button id="share-btn" class="hidden">Share</button> |
| 94 | + ``` |
| 95 | + |
| 96 | + This is redundant because main.ts calls `shareBtn.classList.remove('hidden')` on init. |
| 97 | + However, for code clarity and to ensure the button is visible even if JS fails: |
| 98 | + |
| 99 | + 1. Remove the "hidden" class from the Share button: |
| 100 | + Change: `<button id="share-btn" class="hidden">Share</button>` |
| 101 | + To: `<button id="share-btn">Share</button>` |
| 102 | + |
| 103 | + 2. Instead, add logic in main.ts to hide it on desktop. The current code already does this |
| 104 | + correctly by only calling classList.remove('hidden') when !isDesktop(). |
| 105 | + |
| 106 | + Actually, keep class="hidden" - it's the correct pattern. The button starts hidden, |
| 107 | + then JS removes hidden class on web. This prevents flash of unstyled button on desktop. |
| 108 | + |
| 109 | + CORRECTION: Do NOT modify index.html. The current pattern is correct: |
| 110 | + - Button starts hidden (prevents flash on desktop) |
| 111 | + - JavaScript removes hidden class on web only |
| 112 | + - Desktop never shows button (Tauri has native sharing) |
| 113 | + |
| 114 | + This task is a no-op - the HTML is correct as-is. |
| 115 | + </action> |
| 116 | + <verify>Check that index.html has `<button id="share-btn" class="hidden">Share</button>` - no change needed.</verify> |
| 117 | + <done>HTML structure is correct, no changes needed</done> |
| 118 | +</task> |
| 119 | + |
| 120 | +</tasks> |
| 121 | + |
| 122 | +<verification> |
| 123 | +1. `npx tsc --noEmit` passes |
| 124 | +2. Open viewer in browser (web mode, not Tauri) |
| 125 | +3. Share button visible in toolbar |
| 126 | +4. Click Share button - status shows "Share URL copied!" |
| 127 | +5. Paste URL in new tab - verify URL contains ?l=...&z=...&x=...&y=... parameters |
| 128 | +6. New tab loads with same viewport state (zoom, pan, layer visibility) |
| 129 | +7. Ctrl+Shift+S keyboard shortcut also copies share URL |
| 130 | +</verification> |
| 131 | + |
| 132 | +<success_criteria> |
| 133 | +- WEB-07: User can share designs via URL (viewport-only, not full state) |
| 134 | +- Share button appears on web, hidden on desktop |
| 135 | +- Keyboard shortcut Ctrl+Shift+S works for sharing |
| 136 | +</success_criteria> |
| 137 | + |
| 138 | +<output> |
| 139 | +After completion, create `.planning/phases/16-web-verification-polish/16-02-SUMMARY.md` |
| 140 | +</output> |
0 commit comments