Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Implements actionable, unresolved review feedback from PRs #26 and #6.

src/services/xapi.ts

  • fetchThread Array.isArray guard: response.data was passed to parseThread() with only a truthiness check. A non-array object from an unexpected API shape would throw inside parseThread when reading .length. Now validates with Array.isArray() and returns null with a warning on mismatch.
  • fetchMentions URLSearchParams: Replaced fragile string-concatenated query params with URLSearchParams for proper encoding and readability.

src/services/grok.ts

  • Remove any on API response: Replaced const data: any with a typed assertion and added Array.isArray(data.choices) runtime guard, consistent with the xapi.ts pattern.
  • Validate parsed action type at runtime: Replaced parsed.action as any with validation against the allowed AgentAction['type'] union, falling back to 'analyze' for unrecognized values.
// Before
const data: any = await response.json();
type: parsed.action as any,

// After
const data = await response.json() as { choices?: Array<{ message?: { content?: string } }> };
if (!Array.isArray(data.choices)) {
  throw new Error('Unexpected Grok API response: missing choices array');
}

const validActions: AgentAction['type'][] = ['reply', 'search', 'generate', 'analyze'];
const actionType = validActions.includes(parsed.action) ? parsed.action : 'analyze';

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Resolve actionable items in pending PRs fix: address unresolved review feedback — Array.isArray guard, URLSearchParams, type safety Feb 9, 2026
Copilot AI requested a review from groupthinking February 9, 2026 18:07
@groupthinking
Copy link
Owner

Closing stale draft — superseded by cleanup/ready-to-use merge to main

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