feat: v2.6.0 — Chat UI composer (+ menu, project files, activity panel, permission mode, Stop), git on a workspace's extra folders (#70), long paste as a file (#68), S3 server mode (experimental)
Chat UI: - Each Claude/Codex session keeps its own chat/terminal view; Settings only sets how new sessions open. - Composer + menu: upload, project files and folders (#54, also dragged from the Files/Changes tree), context files, recent uploads, skills, plugins. - Activity side panel (progress, outputs, files read, uploads, memory, skills, connectors) with a file preview; edited-file counts per turn. - Permission-mode chip (Shift+Tab steps, read back from the pane: server/lib/pane-mode.js, GET|POST /api/run/:id/permission-mode). - Stop (Esc) while the main agent works; the status is checked per agent (with session_id /api/agents ignores its status filter) and re-read every 5 s while Stop shows. - Dropped images shown in the conversation (GET /api/run/drop/:name, the requester's own drop dir), full-size viewer. - A plain-text paste over 5,000 characters is attached as pasted-text.txt, so no prompt reaches tmux/argv limits (#68). Changes panel: every /api/lanes/:id/git* route takes ?source=<lane_sources id> (sourceFolder; ENOSOURCE otherwise) and a folder picker switches the whole panel to a workspace's extra folder (#70). Server mode S3 (one Linux user per account) — experimental, verified with fake sudo plus a P6 managed-settings spike on a test account: - member tmux listing runs in the background (cached, 15 s => unknown); - transcript snapshot copy is async, chunked, temp file + rename; - Express Layer patch only on Express 4; - tmux capturePane/sendKey go to the member's own server. Docs: the multi-user design moved in as docs/plans/server-mode/README.md (the AgentHub-Server repo is gone); S3-PLAN P6 result; LANES/API/openapi.
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @file promptAttach.ts
|
||||
* @description What a prompt box can attach besides a fresh upload: a project
|
||||
* file or folder dragged from the Files panel (`ATTACH_MIME`, read back by
|
||||
* `PromptEditor`'s drop) and the files uploaded through a prompt box in the
|
||||
* last day (`recentUploads`, kept in this browser). An attachment is a path
|
||||
* sent with the prompt, so nothing here touches the server.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
import type { DragEvent } from "react";
|
||||
|
||||
/** One attachment, shaped like `PromptImage`: what is sent, and its label. */
|
||||
export interface Attachment {
|
||||
path: string;
|
||||
name: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export const ATTACH_MIME = "application/x-agenthub-attach";
|
||||
|
||||
/** A project path (relative to the box's folder) as Claude Code's `@` mention. */
|
||||
export function projectAttachment(rel: string): Attachment {
|
||||
const name = rel.replace(/\/$/, "").split("/").pop() || rel;
|
||||
return { path: `@${rel}`, name: rel.endsWith("/") ? `${name}/` : name };
|
||||
}
|
||||
|
||||
/** Start a drag carrying `rel` (a Files panel row) to a prompt box; plain
|
||||
* text too, so a drop elsewhere (a terminal, an editor) gets the path. */
|
||||
export function dragProjectPath(e: DragEvent, rel: string) {
|
||||
e.dataTransfer.setData(ATTACH_MIME, JSON.stringify(projectAttachment(rel)));
|
||||
e.dataTransfer.setData("text/plain", rel);
|
||||
e.dataTransfer.effectAllowed = "copy";
|
||||
}
|
||||
|
||||
/** The attachment a drop carries, if it is one of ours. */
|
||||
export function droppedAttachment(dt: DataTransfer | null | undefined): Attachment | null {
|
||||
try {
|
||||
const v: unknown = JSON.parse(dt?.getData(ATTACH_MIME) || "null");
|
||||
const a = v as Attachment | null;
|
||||
return a && typeof a.path === "string" && typeof a.name === "string"
|
||||
? { path: a.path, name: a.name }
|
||||
: null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** `prev` plus whichever of `items` it does not hold yet. */
|
||||
export function addAttachments<T extends Attachment>(prev: T[], items: T[]): T[] {
|
||||
const fresh = items.filter(
|
||||
(a, i) =>
|
||||
!prev.some((p) => p.path === a.path) && items.findIndex((b) => b.path === a.path) === i
|
||||
);
|
||||
return fresh.length ? [...prev, ...fresh] : prev;
|
||||
}
|
||||
|
||||
const RECENT_KEY = "agenthub.prompt.recentUploads";
|
||||
const RECENT_MAX = 20;
|
||||
// The server prunes an upload a day after it was written (`saveDrop`).
|
||||
// ponytail: a client-side guess of that TTL, a few minutes short; a listing
|
||||
// route instead if uploads must outlive it or follow the user to another browser.
|
||||
const RECENT_TTL_MS = 23.9 * 60 * 60_000;
|
||||
|
||||
interface Recent extends Attachment {
|
||||
at: number;
|
||||
}
|
||||
|
||||
function readRecent(): Recent[] {
|
||||
try {
|
||||
const v: unknown = JSON.parse(localStorage.getItem(RECENT_KEY) || "[]");
|
||||
const cutoff = Date.now() - RECENT_TTL_MS;
|
||||
return (Array.isArray(v) ? (v as Recent[]) : []).filter(
|
||||
(r) => typeof r?.path === "string" && typeof r.name === "string" && r.at > cutoff
|
||||
);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function recentUploads(): Attachment[] {
|
||||
return readRecent().map(({ path, name, url }) => ({ path, name, ...(url ? { url } : {}) }));
|
||||
}
|
||||
|
||||
/** Remember uploads just saved, newest first; an image keeps a thumbnail
|
||||
* through `GET /api/run/drop/:name` (its local blob URL dies with the page). */
|
||||
export function rememberUploads(items: { path: string; name: string; image: boolean }[]) {
|
||||
const at = Date.now();
|
||||
const added: Recent[] = items.map(({ path, name, image }) => ({
|
||||
path,
|
||||
name,
|
||||
at,
|
||||
...(image ? { url: `/api/run/drop/${encodeURIComponent(path.split("/").pop() || "")}` } : {}),
|
||||
}));
|
||||
const kept = readRecent().filter((r) => !added.some((a) => a.path === r.path));
|
||||
try {
|
||||
localStorage.setItem(RECENT_KEY, JSON.stringify([...added, ...kept].slice(0, RECENT_MAX)));
|
||||
} catch {
|
||||
/* storage full or blocked: the list is a convenience */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user