This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/web/components/CreatePostWithRepo.tsx
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

121 lines
3.4 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import { useState } from 'react';
import api from '@/services/api';
import { getErrorMessage } from '@/utils/error';
import dynamic from 'next/dynamic';
import { parseRepositoryInput } from '@/utils/repositoryRouting';
const GifPicker = dynamic(() => import('./GifPicker'), { ssr: false });
export default function CreatePostWithRepo() {
const [content, setContent] = useState('');
const [repoUrl, setRepoUrl] = useState('');
const [gifUrl, setGifUrl] = useState('');
const [showGifPicker, setShowGifPicker] = useState(false);
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError('');
setLoading(true);
try {
const repo = parseRepositoryInput(repoUrl);
if (!repo) {
setError('Invalid repository reference');
setLoading(false);
return;
}
await api.post('/posts', {
content,
repoOwner: repo.owner,
repoName: repo.name,
gifUrl: gifUrl || undefined,
});
setContent('');
setRepoUrl('');
setGifUrl('');
window.location.reload(); // Refresh feed
} catch (err: unknown) {
setError(getErrorMessage(err));
} finally {
setLoading(false);
}
};
const handleGifSelect = (url: string) => {
setGifUrl(url);
setShowGifPicker(false);
};
return (
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-4">
<form onSubmit={handleSubmit}>
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
placeholder="What do you think about this project?"
className="w-full p-3 border rounded-lg resize-none"
rows={3}
required
/>
<input
type="text"
value={repoUrl}
onChange={(e) => setRepoUrl(e.target.value)}
placeholder="GitHub URL or owner/repo (e.g., https://github.com/microsoft/vscode)"
className="w-full p-3 border rounded-lg mt-2"
/>
{gifUrl && (
<div className="mt-2 relative">
<img src={gifUrl} alt="Selected GIF" className="rounded-lg max-h-48" />
<button
type="button"
onClick={() => setGifUrl('')}
className="absolute top-2 right-2 bg-black/50 text-white rounded-full p-1 hover:bg-black/70"
>
✕
</button>
</div>
)}
{error && (
<p className="text-red-500 text-sm mt-2">{error}</p>
)}
<div className="flex items-center gap-2 mt-3">
<button
type="button"
onClick={() => setShowGifPicker(true)}
className="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 flex items-center gap-2"
>
<span className="text-lg">🎞️</span>
GIF
</button>
<button
type="submit"
disabled={loading || !content}
className="px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 disabled:opacity-50"
>
{loading ? 'Posting...' : 'Post'}
</button>
</div>
</form>
{showGifPicker && (
<GifPicker
onSelect={handleGifSelect}
onClose={() => setShowGifPicker(false)}
/>
)}
</div>
);
}