feat(phase3): comments, issue compose, PR diff viewer, reviews, merge, checks

- API: comments CRUD, create/edit issue, milestones, collaborators, pull files,
  raw unified diff (getText), reviews, merge, combined commit status
- hooks: comment thread + composer mutations, issue compose mutations,
  pull files/diff/reviews, create review, merge, combined status
- UI: TextArea, ChipSelect, CommentItem, CommentComposer, native DiffView
  (parseDiff), StatusChecks
- screens: IssueCompose (create/edit), PullFiles, PullDiff, PullReview; issue
  detail gains thread + close/reopen; PR detail gains reviews, merge, files,
  checks; commit detail shows checks
- navigation/types + i18n (en/nl) updated; centralized safeHost helper
- tests: diff parser, endpoint body shapes (merge capitalisation), client getText
This commit is contained in:
JustZoe101 committed 2026-10-09 17:02:08 +02:00
1 parent f641238b6f
commit ddd834b7ac
32 files changed
+2546 -68

No files matched your search

@@ -1,18 +1,31 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { CommentItem } from '@/components/git/comment';
import { CommentComposer } from '@/components/git/comment-composer';
import { Markdown } from '@/components/git/markdown';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { Badge, StatusBadge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { LabelChip } from '@/components/ui/label-chip';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { safeHost } from '@/core/api/instance-url';
import type { Comment } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useSession } from '@/features/accounts/use-session';
import { useIssue } from '@/features/issues/queries';
import {
useCreateIssueComment,
useDeleteIssueComment,
useIssue,
useIssueComments,
useUpdateIssue,
useUpdateIssueComment,
} from '@/features/issues/queries';
import { formatRelativeTime } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
@@ -21,15 +34,20 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'IssueDetail'>;
/** Full issue view: state, author, labels, milestone and rendered body. */
export function IssueDetailScreen({ route }: Props) {
/** Full issue view: state, author, labels, milestone, body, comments and composer. */
export function IssueDetailScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { instance } = useSession();
const { instance, account, token } = useSession();
const { owner, name, index } = route.params;
const query = useIssue(owner, name, index);
const issue = query.data;
const commentsQuery = useIssueComments(owner, name, index);
const updateIssue = useUpdateIssue(owner, name, index);
const createComment = useCreateIssueComment(owner, name, index);
const updateComment = useUpdateIssueComment(owner, name, index);
const deleteComment = useDeleteIssueComment(owner, name, index);
if (query.isPending) return <LoadingView />;
if (query.isError) {
@@ -46,6 +64,12 @@ export function IssueDetailScreen({ route }: Props) {
const author = issue.user;
const state = issue.state === 'closed' ? 'closed' : 'open';
const host = instance ? safeHost(instance.baseUrl) : null;
const comments: Comment[] = flattenPages(commentsQuery.data);
const toggleState = () => {
updateIssue.mutate({ state: state === 'closed' ? 'open' : 'closed' });
};
return (
<Screen scroll padded>
@@ -63,6 +87,24 @@ export function IssueDetailScreen({ route }: Props) {
</View>
</View>
<View style={styles.actionRow}>
<Button
label={t('common.edit')}
variant="secondary"
size="md"
iconLeft="edit"
onPress={() => navigation.navigate('IssueCompose', { owner, name, index })}
/>
<Button
label={state === 'closed' ? t('issues.reopen') : t('issues.close')}
variant="secondary"
size="md"
iconLeft={state === 'closed' ? 'refresh' : 'check'}
loading={updateIssue.isPending}
onPress={toggleState}
/>
</View>
<View style={styles.authorRow}>
<Avatar url={author?.avatar_url} name={author?.login ?? '?'} size={28} />
<AppText variant="bodyMedium" style={styles.authorName}>
@@ -72,8 +114,12 @@ export function IssueDetailScreen({ route }: Props) {
{issue.labels && issue.labels.length > 0 ? (
<View style={styles.labels}>
{issue.labels.map((label, index2) => (
<LabelChip key={label.id ?? `${label.name}-${index2}`} name={label.name} color={label.color} />
{issue.labels.map((label, labelIndex) => (
<LabelChip
key={label.id ?? `${label.name}-${labelIndex}`}
name={label.name}
color={label.color}
/>
))}
</View>
) : null}
@@ -97,18 +143,76 @@ export function IssueDetailScreen({ route }: Props) {
})}
/>
) : null}
{issue.milestone ? <MetaRow icon="tag" label={`${t('issues.milestone')}: ${issue.milestone.title}`} /> : null}
{issue.milestone ? (
<MetaRow icon="tag" label={`${t('issues.milestone')}: ${issue.milestone.title}`} />
) : null}
<MetaRow
icon="mail"
label={t('issues.comments', { count: issue.comments ?? 0 })}
label={t('issues.comments', { count: issue.comments ?? comments.length })}
color={colors.textSecondary}
/>
</View>
{/* Comments */}
<AppText variant="subheading" style={styles.sectionTitle}>
{t('comments.title')}
</AppText>
{commentsQuery.isPending ? (
<LoadingView label={t('comments.loading')} />
) : commentsQuery.isError ? (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(commentsQuery.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void commentsQuery.refetch()}
/>
) : comments.length === 0 ? (
<AppText variant="secondary" tone="tertiary">
{t('comments.empty')}
</AppText>
) : (
comments.map((comment) => {
const isOwn = Boolean(account?.login && comment.user?.login === account.login);
const commentId = comment.id;
return (
<CommentItem
key={commentId}
comment={comment}
baseUrl={instance?.baseUrl}
token={token}
host={host}
isOwn={isOwn}
updating={updateComment.isPending}
onUpdate={
commentId
? (body) => updateComment.mutateAsync({ id: commentId, body })
: undefined
}
onDelete={commentId ? () => deleteComment.mutateAsync(commentId) : undefined}
/>
);
})
)}
<CommentComposer
onSubmit={(body) => createComment.mutateAsync(body)}
pending={createComment.isPending}
errorMessage={createComment.isError ? apiErrorMessage(createComment.error, t) : null}
/>
</Screen>
);
}
function MetaRow({ icon, label, color }: { icon: 'person' | 'tag' | 'mail'; label: string; color?: string }) {
function MetaRow({
icon,
label,
color,
}: {
icon: 'person' | 'tag' | 'mail';
label: string;
color?: string;
}) {
const { colors } = useTheme();
return (
<View style={styles.metaRow}>
@@ -123,10 +227,12 @@ function MetaRow({ icon, label, color }: { icon: 'person' | 'tag' | 'mail'; labe
const styles = StyleSheet.create({
titleBlock: { gap: spacing.sm },
stateRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
actionRow: { flexDirection: 'row', gap: spacing.sm, flexWrap: 'wrap' },
authorRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
authorName: { flex: 1 },
labels: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
bodyCard: { minHeight: 80 },
metaGrid: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
sectionTitle: { marginTop: spacing.md },
});