mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(gateway): reviewer/PM collision map (W5)
The collision surface (intends_to_touch / adds_migration / touches_shared)
is authored at delegate time, consumed once by SequencingService to wire
dependency edges, then never shown to a reviewer again. This surfaces it:
- Pure builder (services/gateway/choreographer/collision.py): for a task
under review, the surfaced siblings (same parent) that would collide —
file-overlap globs or a shared migration chain (both adds_migration) —
with the overlapping globs and a declared-vs-actual drift check. No
DB/IO; callers fetch siblings (one indexed get_subtasks query, mig 069)
+ actual files (git). Caps: 10 siblings, 5 globs.
- Evidence envelopes: collision_context block injected into QA
claim_review, PR-gate claim_gate_review (both carry real touched files
so drift is populated), and the PM i_will_plan briefing (no actual
files at plan time, drift omitted). Best-effort — a failure omits the
block, never breaks the verb/briefing. Empty block omitted (zero token
cost via _EVIDENCE_OMIT_WHEN_EMPTY).
- Panel: GET /api/tasks/{id}/collision-map (declared surface + sibling
overlap; no drift — the panel route resolves no workspace) + a Collision
tab on the task detail (8th tab). Mock-mode returns an empty map.
- docs/map added to the RAG auto-index dirs so the collision-map concept
is fleet-retrievable; skipped gracefully if the dir is absent.
19 new tests (15 unit on the pure builder + 4 integration on the route).
Gate green: ruff/mypy/xenon (module rank A)/pytest 13000/coverage 94.81%,
panel typecheck/lint/516 tests.
* [w6-telegram] Add Telegram notifications bridge (V1)
CEO-facing Telegram DM bridge, flag-gated off by default
(ROBOCO_TELEGRAM_ENABLED). Mirrors the X-credentials / X-client pattern:
- TelegramCredentialsTable (migration 073) — singleton Fernet-encrypted
bot_token + chat_id, all-or-nothing set/clear; API never returns plaintext.
- TelegramClient ABC / NullTelegramClient (no-op, configured->False, never
raises) / LiveTelegramClient (httpx POST sendMessage) / build_telegram_client
factory (Null when creds unset).
- /telegram/credentials CEO-only routes (write-only, guard-decorated).
- Best-effort _notify_telegram fan-out from the two CEO-notify producers
(notify_ceo_of_escalation, notify_ceo_of_completion) — guarded by the flag,
never raises into the producer, carries a panel deep-link when
panel_base_url is set.
- panel credentials card (2 fields) nested in the Telegram feature-flag row.
- panel_base_url + telegram_timeout_seconds config fields.
V1 scope only: credentials + flag + panel card + client + one-line fan-out.
Out of scope (V2): inbound commands, a TelegramEngine background loop, a
dedup ledger, a bus subscription.
* [w6-telegram] fix: slave mypy/xenon regression (product tests + helper extract)
Pre-existing on slave from prior session's merges — no PR's CI caught them
(squash merges don't re-CI the result; each branch was based on older slave).
- test_product: _product helper returned MagicMock -> list invariant error;
cast to ProductTable, move import under TYPE_CHECKING.
- test_usage: svc.session.execute (AsyncSession) has no call_args_list;
cast to MagicMock at the two call sites.
- product.progress_for_products: xenon rank C -> extract module-level
_project_to_products_map helper (repo pattern: helper-extract).
---------
Co-authored-by: Renn F <rennf93@users.noreply.github.com>
149 lines
5.1 KiB
TypeScript
149 lines
5.1 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import { telegramApi } from "@/lib/api";
|
|
import { Label } from "@/components/ui/label";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { Key, KeyRound, Save } from "lucide-react";
|
|
import { toast } from "sonner";
|
|
|
|
const FIELDS: Array<{ key: "bot_token" | "chat_id"; label: string }> = [
|
|
{ key: "bot_token", label: "Bot token (from @BotFather)" },
|
|
{ key: "chat_id", label: "Chat id (destination)" },
|
|
];
|
|
|
|
// The CEO's one-time entry of the Telegram bot token + destination chat id.
|
|
// Write-only — the stored values are never displayed back, only whether
|
|
// they're set (mirrors the X / git-token cards). Both are required together:
|
|
// a token alone can't target a DM. Rendered chrome-less so it can nest inside
|
|
// the Telegram feature-flag row.
|
|
export function TelegramCredentialsForm() {
|
|
const queryClient = useQueryClient();
|
|
const [values, setValues] = useState({ bot_token: "", chat_id: "" });
|
|
|
|
const { data: status, isLoading } = useQuery({
|
|
queryKey: ["telegram", "credentials"],
|
|
queryFn: () => telegramApi.getCredentialsStatus(),
|
|
});
|
|
|
|
const saveMutation = useMutation({
|
|
mutationFn: () => telegramApi.setCredentials(values),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["telegram", "credentials"] });
|
|
setValues({ bot_token: "", chat_id: "" });
|
|
toast.success("Telegram credentials saved");
|
|
},
|
|
onError: (error) => {
|
|
toast.error(
|
|
`Failed to save: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
);
|
|
},
|
|
});
|
|
|
|
const allFilled = FIELDS.every((f) => values[f.key].trim().length > 0);
|
|
const noneFilled = FIELDS.every((f) => values[f.key].trim().length === 0);
|
|
const canSave = allFilled || (noneFilled && !!status?.has_credentials);
|
|
const isClearing = noneFilled && !!status?.has_credentials;
|
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<p className="text-sm text-muted-foreground">
|
|
The bot token from <span className="font-medium">@BotFather</span> and the
|
|
chat id to DM (your user/channel id). Stored encrypted server-side; agents
|
|
never see them and this panel never displays them again once saved.
|
|
</p>
|
|
|
|
<div className="flex items-center gap-2 rounded-md border p-3">
|
|
{status?.has_credentials ? (
|
|
<>
|
|
<Key className="h-4 w-4 text-green-500" />
|
|
<span className="text-sm text-green-600 dark:text-green-400">
|
|
Credentials are set
|
|
</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<KeyRound className="h-4 w-4 text-amber-500" />
|
|
<span className="text-sm text-amber-600 dark:text-amber-400">
|
|
{isLoading ? "Checking..." : "No credentials configured"}
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
{FIELDS.map((field) => (
|
|
<div key={field.key} className="space-y-2">
|
|
<Label htmlFor={`tg-cred-${field.key}`}>
|
|
{status?.has_credentials ? `Replace ${field.label}` : field.label}
|
|
</Label>
|
|
<Input
|
|
id={`tg-cred-${field.key}`}
|
|
type="password"
|
|
value={values[field.key]}
|
|
onChange={(e) =>
|
|
setValues((prev) => ({ ...prev, [field.key]: e.target.value }))
|
|
}
|
|
placeholder="••••••••••••"
|
|
/>
|
|
</div>
|
|
))}
|
|
</div>
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
Set both to save (or rotate); leave both blank and save to clear.
|
|
</p>
|
|
|
|
<Button
|
|
onClick={() =>
|
|
isClearing ? setConfirmClear(true) : saveMutation.mutate()
|
|
}
|
|
disabled={saveMutation.isPending || !canSave}
|
|
>
|
|
<Save className="mr-2 h-4 w-4" />
|
|
{saveMutation.isPending ? "Saving..." : "Save"}
|
|
</Button>
|
|
|
|
<AlertDialog
|
|
open={confirmClear}
|
|
onOpenChange={(open) => {
|
|
if (!open) setConfirmClear(false);
|
|
}}
|
|
>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Clear Telegram credentials?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
This will clear the stored bot token and chat id. This cannot be
|
|
undone.
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
<AlertDialogAction
|
|
onClick={() => {
|
|
setConfirmClear(false);
|
|
saveMutation.mutate();
|
|
}}
|
|
>
|
|
Clear
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</div>
|
|
);
|
|
} |