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.
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

120 lines
3.8 KiB
TypeScript

'use client'
import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
import { useAuthStore } from '@/store/authStore'
import { storyService } from '@/services/storyService'
import { useToast } from '@/components/ui/toast'
export default function StoriesPage() {
const router = useRouter()
const { isAuthenticated } = useAuthStore()
const { showToast } = useToast()
const [stories, setStories] = useState<any[]>([])
const [currentIndex, setCurrentIndex] = useState(0)
const [loading, setLoading] = useState(true)
useEffect(() => {
if (!isAuthenticated) {
router.push('/login')
return
}
loadStories()
}, [isAuthenticated])
const loadStories = async () => {
try {
const data = await storyService.getStories()
const groups = Array.isArray(data?.stories) ? data.stories : []
const flattened = groups.flatMap((group: any) =>
Array.isArray(group?.stories)
? group.stories.map((story: any) => ({
...story,
user: story.user ?? group.user,
}))
: []
)
setStories(flattened)
} catch (error: unknown) {
showToast('Failed to load stories', 'error')
} finally {
setLoading(false)
}
}
const handleView = async (storyId: string) => {
try {
await storyService.viewStory(storyId)
} catch (error) {
console.error('Failed to mark story as viewed')
}
}
useEffect(() => {
if (stories[currentIndex]) {
handleView(stories[currentIndex].id)
}
}, [currentIndex])
if (!isAuthenticated || loading) return null
const currentStory = stories[currentIndex]
return (
<div className="fixed inset-0 bg-black">
{currentStory && (
<div className="relative h-full flex items-center justify-center">
{currentStory.mediaType === 'video' ? (
<video
src={currentStory.mediaUrl}
className="h-full w-auto max-w-full object-contain"
autoPlay
playsInline
/>
) : (
<img
src={currentStory.mediaUrl}
alt="Story"
className="h-full w-auto max-w-full object-contain"
/>
)}
<div className="absolute top-4 left-4 right-4 flex items-center gap-3 text-white">
<div className="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center">
<span className="font-semibold">{currentStory.user?.username?.[0]?.toUpperCase()}</span>
</div>
<div className="flex-1">
<p className="font-semibold">{currentStory.user?.username}</p>
<p className="text-sm opacity-80">2h ago</p>
</div>
<button onClick={() => router.back()} className="text-white">✕</button>
</div>
<div className="absolute top-2 left-0 right-0 flex gap-1 px-4">
{stories.map((_, i) => (
<div key={i} className={`h-1 flex-1 rounded ${i === currentIndex ? 'bg-white' : 'bg-white/30'}`} />
))}
</div>
{currentIndex > 0 && (
<button
onClick={() => setCurrentIndex(currentIndex - 1)}
className="absolute left-4 top-1/2 -translate-y-1/2 w-12 h-12 bg-white/20 rounded-full flex items-center justify-center text-white"
>
←
</button>
)}
{currentIndex < stories.length - 1 && (
<button
onClick={() => setCurrentIndex(currentIndex + 1)}
className="absolute right-4 top-1/2 -translate-y-1/2 w-12 h-12 bg-white/20 rounded-full flex items-center justify-center text-white"
>
→
</button>
)}
</div>
)}
</div>
)
}