Skip to content

Feature/voc 14 post to linkedin - #35

Open
FSS3096 wants to merge 8 commits into
Arthakram:mainfrom
FSS3096:feature/VOC-14-post-to-linkedin
Open

Feature/voc 14 post to linkedin#35
FSS3096 wants to merge 8 commits into
Arthakram:mainfrom
FSS3096:feature/VOC-14-post-to-linkedin

Conversation

@FSS3096

@FSS3096 FSS3096 commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Type of Change

  • 🐛 Bug fix

  • - [ ] ✨ New feature

  • - [ ] 🔨 Refactor / tech debt

  • - [ ] 📝 Documentation update

  • - [ ] 🚀 Performance improvement

  • - [ ] 🔧 Config / tooling change

  • ## What Changed

  • -

  • -

  • ## Testing

  • - [ ] Manual testing done

  • - [ ] Existing tests pass

  • - [ ] New tests added (if applicable)

  • ## Screenshots / Demo

  • ## Checklist

  • - [ ] Self-reviewed the code

  • - [ ] No console errors or warnings

  • - [ ] PR title follows type: short description convention

  • - [ ] Linked to relevant issue (closes #)

  • - [ ] Ready for review (not a draft)

FSS3096 added 7 commits July 15, 2026 22:36
- Create components/GenerateButton.tsx with all required states:
  - Idle (no repo): disabled button with muted 'Select a repo first' label
  - Idle (repo selected): primary blue CTA — 'Generate Post from Latest Activity'
  - Loading: button replaced by LoadingView spinner (no double-submit possible)
  - Error: ErrorView with retry + button reappears for retry
  - Success: stores response in sessionStorage['voca_drafts'], push('/drafts)

- Create components/DashboardClient.tsx — Client Component boundary that owns
  selectedRepo state and passes it to both RepoSelector and GenerateButton.
  This cleanly solves the Server Component → state ownership problem without
  prop drilling.

- Refactor components/RepoSelector.tsx to support controlled mode:
  - New optional props: onRepoSelect (callback) + selectedRepo (controlled value)
  - Controlled mode: used by DashboardClient for VOC-131 flow
  - Uncontrolled/legacy mode: original behaviour preserved for existing callers

- Update app/dashboard/page.tsx to use DashboardClient instead of bare
  RepoSelector; page stays a Server Component for auth guard.

Acceptance criteria covered:
  ✅ Button visible after repo selection
  ✅ Button disabled (not hidden) when no repo selected
  ✅ POST /api/generate called with { repoFullName }
  ✅ Loading state replaces button (no double-submit)
  ✅ Error state with retry (coordinates with Arthakram#18)
  ✅ sessionStorage key 'voca_drafts' on success
  ✅ router.push('/drafts') on success
  ✅ Mobile: w-full, capped at max-w-[400px] centered on desktop
  ✅ Accessible: aria-label, aria-disabled, role=status/alert, focus-visible ring

Placeholder stubs for LoadingView and ErrorView are intentionally co-located
in GenerateButton.tsx — swap to real components (Arthakram#17, Arthakram#18) is a one-line
import change.

Relates to: VOC-131
Blocks: Arthakram#17 (loading state), Arthakram#18 (error handling)
Depends on: /api/generate endpoint (Arthakram#15)
…sages

- Create components/LoadingView.tsx with full step cycling behaviour:
  - Step 0 (0–3s):   'Reading your latest commits...'
  - Step 1 (3–6s):   'Finding the most meaningful changes...'
  - Step 2 (6–10s):  'Writing 3 post variations for you...'
  - Step 3 (10–20s): 'Almost there — polishing the drafts...'
  - Step 4 (20s+):   'Taking a bit longer than usual — still working...'
    └─ Infinity duration: never auto-advances, persists until success/error

- Zero layout shift: text container has min-h-[3.5rem] (56px) sized to the
  tallest two-line message, so spinner/dots stay pinned during step transitions

- Dot progress indicator (4 dots for planned steps 0–3):
  - Past and current steps filled (bg-blue-600)
  - Future steps muted (bg-gray-300)
  - Overflow step (4): all dots filled to signal 'phases complete, waiting on API'

- Overflow sub-label on step 4 sets correct expectations
  ('Complex repositories... can take up to 30 seconds')

- Memory safe: clearTimeout in useEffect cleanup prevents leaks if the
  component unmounts mid-timer (error fires, user navigates away, etc.)

- Accessible: role=status, aria-live=polite, aria-label, aria-hidden on
  decorative spinner

- Update components/GenerateButton.tsx: swap inline LoadingView stub for
  real import from VOC-132 (one-line change as designed)

Acceptance criteria:
  ✅ Zero delay render (fully client-side, no API calls)
  ✅ Steps auto-advance at correct timings (±500ms)
  ✅ Step 5 appears only after 20s, never auto-advances
  ✅ Spinner animates continuously
  ✅ Dot indicators correctly highlight current step
  ✅ Mobile responsive (px-4, max-w-sm text, flex layout)
  ✅ No memory leaks (clearTimeout in cleanup)
  ✅ No layout shift (min-h reserved on text container)

Linear: VOC-132
Depends on: VOC-131 (Arthakram#16)
Blocks: VOC-133 (Arthakram#18)
- Create components/ErrorView.tsx mapped to 7 distinct error scenarios
- Integrate ErrorView into GenerateButton component with AbortController timeout (45s)
- Implement pages/api/generate.ts with server-side error logging (not logging user access tokens) and test hooks for all 7 error types
- Update RepoSelector.tsx to display test trigger options for manual validation
- Update VOCA_PROGRESS.md with Epic 5 checklist and manual test verification logs
- Create app/drafts/page.tsx to render 3 posts from sessionStorage
- Create components/DraftCard.tsx to display draft with edit, copy, share, character count
- Implement real-time propagation of inline edits to local state and sessionStorage
- Implement LinkedIn sharing deep link with URL-encoded text compose
- Integrate LoadingView and ErrorView on drafts page for regeneration triggers
…-resize

- Style textarea to look like plain text until focused (borderless, bg-transparent)
- On focus, trigger subtle background color transition (bg-gray-50)
- Implement dynamic auto-resizing via ref and scrollHeight to eliminate internal scrollbars
- Add protection against cursor jumps by checking content equivalence before syncing state
@AradhyaTiwari10

Copy link
Copy Markdown
Contributor

A few issues to address before merging.

Issues to address

  1. components/DraftCard.tsx

useEffect(() => {
if (content !== localContent) {
setLocalContent(content);
}
}, [content]);

localContent is read inside the effect but is not included in the dependency array. Update the effect so it follows the React Hooks dependency rules.

  1. components/GenerateButton.tsx

const data: any = await res.json().catch(() => ({}))
catch (err: any)

Replace any with unknown in both places and narrow the types before use.

  1. RepoSelector.tsx

The test repo entries are added unconditionally after every successful fetch. Gate this block so it only runs when process.env.NODE_ENV !== 'production'.

  1. pages/api/generate.ts

The trigger-auth-expired override runs before the session check. Move it to after the session guard.

  1. components/DraftCard.tsx

const handleLinkedInShare = async () => {
try {
await navigator.clipboard.writeText(localContent);
} catch (err) { ... }
window.open(url, '_blank', 'noopener,noreferrer');
};

window.open is called after an await, which means the call no longer happens directly within the original user interaction. The popup may be blocked in browsers such as Safari. Consider opening the window before the asynchronous clipboard operation, or restructuring the handler so window.open runs within the synchronous part of the user event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants