diff --git a/README.md b/README.md index 07c81d5..adfb2c6 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ These instructions have been tested on a clean machine to ensure a reliable setu > **Note:** If the repository already includes `.env.example`, you only need to copy it to `.env`. Creating a new `.env.example` is only necessary if the file is missing. - 5. **Start the development server:** ```bash bun dev diff --git a/src/lib/api/github.ts b/src/lib/api/github.ts index 3816c83..d1cb00c 100644 --- a/src/lib/api/github.ts +++ b/src/lib/api/github.ts @@ -137,21 +137,19 @@ export async function searchIssues( const issues = data.items .filter((item) => !item.pull_request) - .map( - (item): Issue => ({ - number: item.number, - title: item.title, - body: item.body, - user: item.user, - labels: item.labels, - assignees: item.assignees, - comments_count: item.comments, - created_at: item.created_at, - updated_at: item.updated_at, - html_url: item.html_url, - state: item.state, - }), - ); + .map((item): Issue => ({ + number: item.number, + title: item.title, + body: item.body, + user: item.user, + labels: item.labels, + assignees: item.assignees, + comments_count: item.comments, + created_at: item.created_at, + updated_at: item.updated_at, + html_url: item.html_url, + state: item.state, + })); allIssues.push(...issues); @@ -190,15 +188,13 @@ export async function fetchIssueComments( const data = await response.json(); - return data.map( - (c: Record): Comment => ({ - id: c.id as number, - user: c.user as Comment['user'], - body: c.body as string, - created_at: c.created_at as string, - updated_at: c.updated_at as string, - }), - ); + return data.map((c: Record): Comment => ({ + id: c.id as number, + user: c.user as Comment['user'], + body: c.body as string, + created_at: c.created_at as string, + updated_at: c.updated_at as string, + })); } export async function fetchIssueTimeline( @@ -217,16 +213,14 @@ export async function fetchIssueTimeline( const data: Record[] = await response.json(); - return data.map( - (e): TimelineEvent => ({ - event: e.event as string, - created_at: e.created_at as string, - actor: e.actor as TimelineEvent['actor'], - source: e.source as TimelineEvent['source'], - commit_id: e.commit_id as string | undefined, - label: e.label as TimelineEvent['label'], - }), - ); + return data.map((e): TimelineEvent => ({ + event: e.event as string, + created_at: e.created_at as string, + actor: e.actor as TimelineEvent['actor'], + source: e.source as TimelineEvent['source'], + commit_id: e.commit_id as string | undefined, + label: e.label as TimelineEvent['label'], + })); } catch { return []; } diff --git a/src/store/appStore.test.ts b/src/store/appStore.test.ts index 68d6a69..429533d 100644 --- a/src/store/appStore.test.ts +++ b/src/store/appStore.test.ts @@ -73,6 +73,15 @@ describe('useAppStore (Zustand Global State)', () => { expect(useAppStore.getState().maxIssues).toBe(CONFIG.MIN_MAX_ISSUES); }); + it('falls back to the default when setMaxIssues receives NaN', () => { + // e.g. the settings number input being cleared mid-edit + useAppStore.getState().setMaxIssues(NaN); + expect(useAppStore.getState().maxIssues).toBe(CONFIG.DEFAULT_MAX_ISSUES); + + useAppStore.getState().setMaxIssues(200); + expect(useAppStore.getState().maxIssues).toBe(200); + }); + it('sets fetch progress correctly', () => { useAppStore.getState().setFetchProgress({ phase: 'analyzing', current: 5, total: 10 }); expect(useAppStore.getState().fetchProgress).toEqual({ diff --git a/src/store/appStore.ts b/src/store/appStore.ts index 19e4889..b4fedb7 100644 --- a/src/store/appStore.ts +++ b/src/store/appStore.ts @@ -191,7 +191,11 @@ export const useAppStore = create((set, get) => ({ // Settings maxIssues: CONFIG.DEFAULT_MAX_ISSUES, setMaxIssues: (max) => - set({ maxIssues: Math.max(CONFIG.MIN_MAX_ISSUES, Math.min(CONFIG.MAX_MAX_ISSUES, max)) }), + set({ + maxIssues: Number.isFinite(max) + ? Math.max(CONFIG.MIN_MAX_ISSUES, Math.min(CONFIG.MAX_MAX_ISSUES, max)) + : CONFIG.DEFAULT_MAX_ISSUES, + }), // History history: [],