feat(phase4): Quick Edit, Contents API commit flow, editor workspace

- portable UTF-8 base64 helpers (Hermes-safe), used for file round-trips
- endpoints: updateFileContents, createFileContents, createPull
- hooks: useCommitFile (invalidates repo cache), useCreatePull
- FileEdit screen: native monospace editor, dirty/discard, branch picker,
  commit-to-new-branch, protected-branch handling, post-commit PR creation;
  stale-SHA 409 surfaces as a conflict message
- settings: editor URL template; repo overview 'Open in editor' (no token)
- tests: base64 round-trips (accents/emoji), editor URL expansion
This commit is contained in:
JustZoe101 committed 2026-10-09 17:19:06 +02:00
1 parent ddd834b7ac
commit c9dd49446a
18 files changed
+733 -29

No files matched your search

@@ -13,9 +13,11 @@ import { LabelChip } from '@/components/ui/label-chip';
import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { buildEditorUrl } from '@/core/utils/editor-url';
import { useRepository, useRepositoryLanguages } from '@/features/repositories/queries';
import { useReadme } from '@/features/repository/queries';
import { decodeBase64, useReadme } from '@/features/repository/queries';
import { useSession } from '@/features/accounts/use-session';
import { useSettingsStore } from '@/features/settings/settings-store';
import { useTheme } from '@/theme/theme-provider';
import { radius, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
@@ -28,6 +30,7 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { instance } = useSession();
const editorUrlTemplate = useSettingsStore((s) => s.editorUrlTemplate);
const { owner, name, ref } = route.params;
const repoQuery = useRepository(owner, name);
@@ -107,6 +110,23 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
onPress={() => void Linking.openURL(repo.html_url as string).catch(() => undefined)}
/>
) : null}
{editorUrlTemplate ? (
<Button
label={t('repo.openInEditor')}
variant="secondary"
iconLeft="externalLink"
onPress={() => {
const url = buildEditorUrl(editorUrlTemplate, {
owner,
name,
cloneUrl: repo.clone_url,
htmlUrl: repo.html_url,
});
void Linking.openURL(url).catch(() => undefined);
}}
/>
) : null}
</View>
{/* Quick navigation */}
@@ -265,11 +285,7 @@ function languageColor(index: number, fallback: string): string {
function decodeReadme(content: string | undefined): string {
if (!content) return '';
try {
return globalThis.atob(content.replace(/\s/g, ''));
} catch {
return '';
}
return decodeBase64(content);
}
const styles = StyleSheet.create({