main.html

309 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{block "title" .}}Congo Dev{{end}}</title>
    <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect width='100' height='100' rx='20' fill='%234f46e5'/><path d='M50 20L20 35v30l30 15 30-15V35z' fill='none' stroke='white' stroke-width='6' stroke-linejoin='round'/><path d='M50 50L20 35M50 50v30M50 50l30-15' fill='none' stroke='white' stroke-width='4' stroke-linecap='round'/></svg>" />
    <link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css" />
    <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github.min.css">
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/go.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/bash.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/javascript.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/typescript.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/json.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/xml.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/css.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/yaml.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/dockerfile.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/makefile.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/markdown.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/sql.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/python.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/ruby.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/rust.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/ini.min.js"></script>
    {{frontend_script}}
    <style>
        body {
            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 40%, #eef2ff 70%, #f5f3ff 100%);
            min-height: 100vh;
        }

        .ring-gauge { transition: stroke-dasharray 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

        @keyframes soft-pulse {
            0%, 100% { opacity: 0.4; }
            50% { opacity: 1; }
        }
        .status-pulse { animation: soft-pulse 2s ease-in-out infinite; }

        .bar-fill { transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }

        .source-lines {
            display: grid;
            grid-template-columns: auto 1fr;
        }
        .source-lines .line-nums {
            text-align: right;
            padding: 1rem 0.75rem 1rem 1rem;
            user-select: none;
            white-space: pre;
            color: rgba(148, 163, 184, 0.5);
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            font-size: 0.75rem;
            line-height: 1.7;
            border-right: 1px solid #f1f5f9;
        }
        .source-lines pre {
            margin: 0;
            padding: 1rem;
            font-size: 0.75rem;
            line-height: 1.7;
            overflow-x: auto;
        }
        .source-lines pre code {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        }

        /* Panel cards */
        .panel-card {
            background: rgba(255, 255, 255, 0.85);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 0.875rem;
            border: 1px solid rgba(226, 232, 240, 0.5);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
            transition: box-shadow 0.3s ease, border-color 0.3s ease;
        }
        .panel-card:hover {
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
            border-color: rgba(226, 232, 240, 0.8);
        }

        /* Shimmer loading */
        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }
        .shimmer {
            background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s ease-in-out infinite;
        }

        /* Toast */
        @keyframes toast-in {
            from { transform: translateX(1rem); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        @keyframes toast-out {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(1rem); opacity: 0; }
        }
        .toast-enter { animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
        .toast-exit { animation: toast-out 0.2s ease-in forwards; }

        .btn-press { transition: transform 0.1s ease; }
        .btn-press:active { transform: scale(0.97); }

        .glow-emerald { box-shadow: 0 0 6px rgba(16, 185, 129, 0.3); }
        .glow-red { box-shadow: 0 0 6px rgba(239, 68, 68, 0.3); }
        .glow-amber { box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }

        .htmx-settling { opacity: 0.9; transition: opacity 0.15s ease; }
        .htmx-swapping { opacity: 0.6; transition: opacity 0.1s ease; }

        @keyframes fade-up {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .fade-up { animation: fade-up 0.3s ease-out; }

        /* Agent drawer */
        body.has-drawer #agent-drawer { transform: translateX(0); }
        body.has-drawer #drawer-backdrop { opacity: 1; pointer-events: auto; }

        .user-bubble {
            background: linear-gradient(135deg, #6366f1, #818cf8);
            color: white;
            border-radius: 1rem 1rem 0.25rem 1rem;
        }
        .agent-bubble {
            background: rgba(241, 245, 249, 0.8);
            border: 1px solid rgba(226, 232, 240, 0.5);
            border-radius: 1rem 1rem 1rem 0.25rem;
        }
        .agent-prose pre {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 0.5rem;
            padding: 0.75rem;
            margin: 0.5rem 0;
            overflow-x: auto;
            font-size: 0.75rem;
        }
        .agent-prose code {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            font-size: 0.8em;
        }
        .agent-prose code:not(pre code) {
            background: rgba(99, 102, 241, 0.1);
            color: #4f46e5;
            padding: 0.1em 0.35em;
            border-radius: 0.25rem;
        }
        .agent-prose strong { color: #334155; }
    </style>
</head>
<body class="min-h-screen">

    <!-- Navbar -->
    <nav class="bg-white/80 backdrop-blur-xl border-b border-slate-200/40 sticky top-0 z-50 px-5 h-12 flex items-center shadow-sm shadow-slate-900/[0.03]">
        <div class="flex-1">
            <a href="/" class="flex items-center gap-2 text-sm font-bold text-slate-800 hover:text-indigo-600 transition-colors group">
                <div class="w-6 h-6 rounded-md bg-gradient-to-br from-indigo-500 to-indigo-700 flex items-center justify-center group-hover:from-indigo-600 group-hover:to-indigo-800 transition-all shadow-sm shadow-indigo-600/25">
                    <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" /></svg>
                </div>
                {{app_name}}
            </a>
        </div>
        {{if auth.CurrentUser}}
        <div class="flex items-center gap-0.5">
            {{if dashboard.HasDomain}}
            <span class="text-[10px] text-slate-300 font-mono hidden lg:inline mr-2">{{dashboard.Domain}}</span>
            {{end}}
            <a href="/coder/" target="_blank" class="inline-flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[11px] font-medium text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors" title="Open Code Editor">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
                <span class="hidden sm:inline">Code</span>
            </a>
            <a href="/getting-started" hx-boost="true" class="inline-flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[11px] font-medium text-slate-400 hover:text-amber-600 hover:bg-amber-50 transition-colors" title="Getting Started Guide">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" /></svg>
                <span class="hidden sm:inline">Guide</span>
            </a>
            <a href="/work/tasks" class="inline-flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[11px] font-medium text-slate-400 hover:text-emerald-600 hover:bg-emerald-50 transition-colors" title="Tasks & Plans">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
                <span class="hidden sm:inline">Work</span>
            </a>
            <a href="https://ping.congo.gg" target="_blank" class="inline-flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[11px] font-medium text-slate-400 hover:text-violet-600 hover:bg-violet-50 transition-colors" title="Chat with Twin">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/></svg>
                <span class="hidden sm:inline">Twin</span>
            </a>
            <div class="dropdown dropdown-end ml-1">
                <div tabindex="0" role="button" class="inline-flex items-center gap-1.5 px-1.5 h-7 rounded-md text-slate-400 hover:bg-slate-100 transition-colors cursor-pointer">
                    <div class="w-5 h-5 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center text-[9px] font-bold uppercase">
                        {{slice auth.CurrentUser.Username 0 1}}
                    </div>
                    <span class="hidden md:inline text-[11px] text-slate-500">{{auth.CurrentUser.Username}}</span>
                </div>
                <ul tabindex="0" class="dropdown-content menu bg-white rounded-lg z-[1] w-48 p-1 shadow-lg border border-slate-200 mt-1">
                    <li><button class="text-[11px] text-slate-600" onclick="document.getElementById('password-modal').showModal()">Change password</button></li>
                    <li class="border-t border-slate-100 mt-1 pt-1"><form method="POST" action="/logout"><button type="submit" class="text-red-500 text-[11px]">Logout</button></form></li>
                </ul>
            </div>
        </div>
        {{end}}
    </nav>

    <!-- Content -->
    <main class="max-w-[1100px] mx-auto px-4 py-4">
        {{block "content" .}}{{end}}
    </main>

    <script>
    hljs.configure({ ignoreUnescapedHTML: true });
    function highlightCode() {
        document.querySelectorAll('pre code[class*="language-"]').forEach(function(el) {
            if (!el.dataset.highlighted) hljs.highlightElement(el);
        });
    }
    highlightCode();
    document.body.addEventListener('htmx:afterSettle', function() { highlightCode(); });
    </script>

    <!-- Password Change Modal -->
    {{if auth.CurrentUser}}
    <dialog id="password-modal" class="modal modal-bottom sm:modal-middle">
        <div class="modal-box bg-white border border-slate-200 shadow-xl max-w-sm p-5">
            <h3 class="text-base font-bold text-slate-800 mb-4">Change Password</h3>
            <form method="dialog"><button class="btn btn-sm btn-circle btn-ghost absolute right-3 top-3 text-slate-300">x</button></form>
            <form hx-post="/account/password" hx-target="body">
                <div class="space-y-3">
                    <input type="password" name="current_password" placeholder="Current password" required autocomplete="current-password"
                        class="w-full text-[12px] text-slate-600 bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 focus:outline-none focus:border-indigo-300 focus:ring-1 focus:ring-indigo-100" />
                    <input type="password" name="new_password" placeholder="New password" required minlength="8" autocomplete="new-password"
                        class="w-full text-[12px] text-slate-600 bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 focus:outline-none focus:border-indigo-300 focus:ring-1 focus:ring-indigo-100" />
                    <input type="password" name="confirm_password" placeholder="Confirm new password" required minlength="8" autocomplete="new-password"
                        class="w-full text-[12px] text-slate-600 bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 focus:outline-none focus:border-indigo-300 focus:ring-1 focus:ring-indigo-100" />
                </div>
                <div class="flex justify-end gap-2 mt-4">
                    <button type="button" class="btn btn-ghost btn-sm" onclick="document.getElementById('password-modal').close()">Cancel</button>
                    <button type="submit" class="btn btn-primary btn-sm">Update</button>
                </div>
            </form>
        </div>
        <form method="dialog" class="modal-backdrop bg-black/10"><button>close</button></form>
    </dialog>
    {{end}}

    <!-- Agent Drawer -->
    {{if auth.CurrentUser}}
    <div id="drawer-backdrop" class="fixed inset-0 bg-black/10 backdrop-blur-[1px] z-[55] opacity-0 pointer-events-none transition-opacity duration-300" onclick="document.body.classList.remove('has-drawer')"></div>
    {{template "agent-drawer.html" .}}
    {{end}}

    <!-- Toast Container -->
    <div id="toast-container" class="fixed top-14 right-4 z-[100] space-y-2 pointer-events-none"></div>

    <script>
    function showToast(message, type) {
        var container = document.getElementById('toast-container');
        var toast = document.createElement('div');
        var styles = {
            success: { bg: 'bg-white border border-emerald-200', text: 'text-emerald-700', icon: '<svg class="w-4 h-4 text-emerald-500 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>' },
            error: { bg: 'bg-white border border-red-200', text: 'text-red-700', icon: '<svg class="w-4 h-4 text-red-500 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>' },
            info: { bg: 'bg-white border border-indigo-200', text: 'text-indigo-700', icon: '<svg class="w-4 h-4 text-indigo-500 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>' }
        };
        var s = styles[type] || styles.info;
        toast.className = 'pointer-events-auto flex items-center gap-2.5 px-4 py-2.5 rounded-lg shadow-lg text-[12px] font-medium toast-enter ' + s.bg + ' ' + s.text;
        toast.innerHTML = s.icon + '<span>' + message + '</span>';
        container.appendChild(toast);
        setTimeout(function() {
            toast.classList.remove('toast-enter');
            toast.classList.add('toast-exit');
            setTimeout(function() { toast.remove(); }, 200);
        }, 3000);
    }

    document.body.addEventListener('htmx:afterRequest', function(e) {
        var el = e.detail.elt;
        if (!el || e.detail.failed) return;
        if (el.tagName === 'BUTTON' && el.getAttribute('hx-post')) {
            var action = el.getAttribute('title') || el.textContent.trim();
            if (action && action.length < 30) {
                showToast(action + ' completed', 'success');
            }
        }
    });

    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape' && document.body.classList.contains('has-drawer')) {
            document.body.classList.remove('has-drawer');
        }
        if (e.key === '/' && !e.ctrlKey && !e.metaKey) {
            var tag = document.activeElement.tagName;
            if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return;
            e.preventDefault();
            document.body.classList.add('has-drawer');
            setTimeout(function() {
                var input = document.getElementById('agent-input');
                if (input) input.focus();
            }, 300);
        }
    });
    </script>
</body>
</html>