diff --git a/AGENTS.md b/AGENTS.md index 660b8da..a3ffdf3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,6 +49,8 @@ Use `.env.local` for local secrets. Keep `.env.local` and any real token-bearing - URLs can be deleted from the URLs list. User-added URLs are removed from storage; generated known URLs are hidden through the stored deleted-base list. - Add Issue is enabled only when the active tab's base URL is already in the URLs list and has a linked Gitea repo. The issue form must show the target repo, capture visible-tab screenshots, accept Gitea-friendly file attachments, and include `Chrome profile: Silma` in created issue bodies. - If the Ready checkbox is checked, create the issue first, upload screenshots/files as issue assets second, and apply the `ready` label last. +- The Add Issue view also lists existing issues for the linked Gitea repo. Selecting an issue must show a comment form that can add text, take additional screenshots, attach files, upload those files as issue assets, and submit a Gitea comment with attachment links. +- Keep the Add Issue view dense; do not show the redundant view header title/description inside this view, and keep the Ready checkbox label short. - The extension requests `activeTab` and `` host permission so screenshots can be captured from the current Chrome tab even after the side panel has stayed open across tab changes. ## Chrome Extension Management diff --git a/README.md b/README.md index 66f69d8..4ce109d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The deployable extension output is `dist/`. Load `dist/` in Chrome as an unpacke Static assets, including the extension icon assets, live in `public/` and are copied into `dist/` during the build. -The app opens in the Chrome side panel. The top icon menu includes Add URL, URLs, Gitea repos, Workspaces, and Add Issue. Add URL is enabled only for an active tab base URL that is not already in the URLs list. URLs can be deleted from the list. Add Issue is enabled when the active tab base URL is already linked to a Gitea repo; it creates an issue, uploads screenshots and files as issue assets, and can apply the `ready` label after uploads. +The app opens in the Chrome side panel. The top icon menu includes Add URL, URLs, Gitea repos, Workspaces, and Add Issue. Add URL is enabled only for an active tab base URL that is not already in the URLs list. URLs can be deleted from the list. Add Issue is enabled when the active tab base URL is already linked to a Gitea repo; it creates an issue, uploads screenshots and files as issue assets, and can apply the `ready` label after uploads. The same view lists existing repo issues; selecting one opens a comment form with screenshots and file attachments. Builds generate `public/local-context.json` from `/Users/Tabitha/.openclaw/workspace_Father`. That snapshot links known workspaces to local Gitea repos and is copied into `dist/` so the built extension is self-contained. diff --git a/docs/extension-management.md b/docs/extension-management.md index 922130e..812c5d1 100644 --- a/docs/extension-management.md +++ b/docs/extension-management.md @@ -39,10 +39,13 @@ Required variables: - Add Issue is enabled only when the active tab's base URL is already in the URLs list and that URL is linked to a Gitea repo. - The Add Issue view must show the Gitea repo that will receive the issue. +- The Add Issue view intentionally omits the redundant view header title/description and keeps the Ready checkbox label short. - Screenshot capture uses Chrome's visible-tab capture API and requires the extension's `activeTab` permission plus `` host permission so capture still works after the side panel remains open across tab changes. - Captured screenshots should appear immediately in Add Issue as thumbnail rows. - Created issue bodies must include `Chrome profile: Silma`. - When Ready is checked, create the issue, upload screenshots/files as Gitea issue assets, then apply the `ready` label last. +- The Add Issue view lists existing issues for the linked Gitea repo. Selecting an issue opens a comment form for text, additional screenshots, and file attachments. +- Issue comments should upload screenshots/files as issue assets first, then create a comment containing links to those attachments. ## URL Management diff --git a/llm.txt b/llm.txt index fabff1f..e730efa 100644 --- a/llm.txt +++ b/llm.txt @@ -19,7 +19,7 @@ Important files: Build with `npm run build`. The deployable output directory is `dist/`; load that folder in Chrome as an unpacked extension or point deployment tooling at it. Do not edit `dist/` directly. -UI behavior: the app renders as a Chrome side panel, not a draggable window. The menu items are Add URL, URLs, Gitea Repos, Workspaces, and Add Issue. Add URL is enabled only when the active tab base URL is not already known; the user must choose either a workspace or a Gitea repo, and the app infers the linked counterpart. URLs can be deleted from the list; user-added URLs are removed from storage, while generated known URLs are hidden through stored deleted bases. Add Issue is enabled only when the active tab base URL is known and linked to a Gitea repo. It shows the target repo, captures visible-tab screenshots with thumbnails, accepts file attachments, creates the Gitea issue, uploads assets, then applies the `ready` label if requested. Created issue bodies include `Chrome profile: Silma`. Gitea repos are ordered by latest default-branch commit. Workspace and URL views show established links between local workspaces, known URLs, and Gitea repos. +UI behavior: the app renders as a Chrome side panel, not a draggable window. The menu items are Add URL, URLs, Gitea Repos, Workspaces, and Add Issue. Add URL is enabled only when the active tab base URL is not already known; the user must choose either a workspace or a Gitea repo, and the app infers the linked counterpart. URLs can be deleted from the list; user-added URLs are removed from storage, while generated known URLs are hidden through stored deleted bases. Add Issue is enabled only when the active tab base URL is known and linked to a Gitea repo. It shows the target repo, captures visible-tab screenshots with thumbnails, accepts file attachments, creates the Gitea issue, uploads assets, then applies the `ready` label if requested. Created issue bodies include `Chrome profile: Silma`. The Add Issue view also lists existing issues for the linked repo; selecting an issue opens a comment form with text, screenshots, and file attachments. Gitea repos are ordered by latest default-branch commit. Workspace and URL views show established links between local workspaces, known URLs, and Gitea repos. Extension management rule: use the Codex Chrome extension with the Chrome profile named `Silma`. Do not use `Profile 1`. diff --git a/manifest.llm.json b/manifest.llm.json index b704000..c942c6d 100644 --- a/manifest.llm.json +++ b/manifest.llm.json @@ -50,7 +50,8 @@ "repo_ordering": "Gitea repos are ordered by latest default-branch commit timestamp.", "add_url_behavior": "The user must pick either a workspace or a Gitea repo. The app infers the linked counterpart from local context and stores the URL link in chrome.storage.local.", "delete_url_behavior": "URLs can be deleted from the list. User-added URLs are removed from chrome.storage.local; generated known URLs are hidden by storing their base URL in silmaAide.deletedUrlBases.", - "add_issue_behavior": "The form shows the target repo for the active known URL, captures visible-tab screenshots with thumbnails, accepts file attachments, creates a Gitea issue, uploads screenshots/files as issue assets, then applies the ready label after uploads when requested. Issue bodies include Chrome profile: Silma.", + "add_issue_behavior": "The form shows the target repo for the active known URL, captures visible-tab screenshots with thumbnails, accepts file attachments, creates a Gitea issue, uploads screenshots/files as issue assets, then applies the ready label after uploads when requested. Issue bodies include Chrome profile: Silma. The view intentionally omits the redundant Add Issue header copy and keeps the Ready checkbox label short.", + "issue_comment_behavior": "The Add Issue view lists existing issues for the active URL's linked Gitea repo. Selecting an issue opens a comment form that accepts text, screenshots, and file attachments, uploads attachments as issue assets, and submits a Gitea issue comment with attachment links.", "known_urls": [ { "url": "http://100.66.226.22:23030/", diff --git a/src/api.ts b/src/api.ts index 83b5f45..e6ed2e5 100644 --- a/src/api.ts +++ b/src/api.ts @@ -41,7 +41,14 @@ interface GiteaBranchResponse { interface GiteaIssueResponse { number?: number; + title?: string; + state?: string; html_url?: string; + updated_at?: string; + user?: { + login?: string; + }; + comments?: number; } interface GiteaLabelResponse { @@ -49,11 +56,31 @@ interface GiteaLabelResponse { name: string; } +interface GiteaAttachmentResponse { + name?: string; + browser_download_url?: string; +} + export interface CreatedGiteaIssue { number: number; webUrl: string; } +export interface GiteaIssueSummary { + number: number; + title: string; + state: string; + webUrl: string; + updatedAt: string; + author: string; + comments: number; +} + +export interface GiteaIssueAttachment { + name: string; + downloadUrl: string; +} + export interface GiteaRepoSummary { name: string; fullName: string; @@ -124,18 +151,62 @@ export async function createGiteaIssue(owner: string, repo: string, title: strin }; } +export async function getGiteaIssues(owner: string, repo: string): Promise { + const client = createGiteaClient(); + const response = await client.get(`/repos/${owner}/${repo}/issues`, { + params: { + limit: 25, + page: 1, + state: "all", + type: "issues" + } + }); + + return response.data + .filter((issue) => issue.number !== undefined) + .map((issue) => ({ + number: issue.number ?? 0, + title: issue.title || "Untitled issue", + state: issue.state || "unknown", + webUrl: issue.html_url || `${giteaConfig.baseUrl.replace(/\/+$/, "")}/${owner}/${repo}/issues/${issue.number}`, + updatedAt: issue.updated_at || "", + author: issue.user?.login || "unknown", + comments: issue.comments ?? 0 + })); +} + export async function uploadGiteaIssueAttachment( owner: string, repo: string, issueNumber: number, file: Blob, fileName: string -): Promise { +): Promise { const client = createGiteaClient(); const formData = new FormData(); formData.append("attachment", file, fileName); - await client.post(`/repos/${owner}/${repo}/issues/${issueNumber}/assets`, formData); + const response = await client.post( + `/repos/${owner}/${repo}/issues/${issueNumber}/assets`, + formData + ); + + return { + name: response.data.name || fileName, + downloadUrl: response.data.browser_download_url || "" + }; +} + +export async function createGiteaIssueComment( + owner: string, + repo: string, + issueNumber: number, + body: string +): Promise { + const client = createGiteaClient(); + await client.post(`/repos/${owner}/${repo}/issues/${issueNumber}/comments`, { + body + }); } async function getGiteaLabels(owner: string, repo: string): Promise { diff --git a/src/main.ts b/src/main.ts index fd6a503..569457c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ import { type AppView, type ScreenshotAttachment } from "./store"; -import type { GiteaRepoSummary } from "./api"; +import type { GiteaIssueSummary, GiteaRepoSummary } from "./api"; import type { KnownUrl, LocalContext, LocalWorkspace } from "./localContext"; const status = document.querySelector("#status"); @@ -43,9 +43,9 @@ function escapeHtml(value: string): string { }); } -function formatDate(value: string): string { +function formatDate(value: string, emptyText = "No date"): string { if (!value) { - return "No commit date"; + return emptyText; } return new Intl.DateTimeFormat(undefined, { @@ -122,7 +122,7 @@ function renderRepos(repos: GiteaRepoSummary[]): string { ${escapeHtml(repo.fullName)} ${escapeHtml(repo.lastCommitMessage)} - ${formatDate(repo.lastCommitAt)} + ${formatDate(repo.lastCommitAt, "No commit date")} ${formatSha(repo.lastCommitSha)} ${getRepoWorkspaceLink(repo)} @@ -294,11 +294,13 @@ function renderAttachmentList(items: string[], emptyText: string): string { `; } -function renderScreenshotList(screenshots: ScreenshotAttachment[]): string { +function renderScreenshotList(screenshots: ScreenshotAttachment[], deleteAction: "issue" | "comment"): string { if (!screenshots.length) { return `No screenshots captured.`; } + const attribute = deleteAction === "issue" ? "data-delete-screenshot" : "data-delete-comment-screenshot"; + return `
${screenshots @@ -307,7 +309,7 @@ function renderScreenshotList(screenshots: ScreenshotAttachment[]): string {
${escapeHtml(screenshot.name)}
${escapeHtml(screenshot.name)}
- +
` ) @@ -316,6 +318,93 @@ function renderScreenshotList(screenshots: ScreenshotAttachment[]): string { `; } +function renderIssueRows(issues: GiteaIssueSummary[], selectedIssueNumber: number | null): string { + if (!issues.length) { + return `
No issues found for this repo.
`; + } + + return ` +
+ ${issues + .map( + (issue) => ` + + ` + ) + .join("")} +
+ `; +} + +function renderIssueCommentForm(issue: GiteaIssueSummary): string { + const state = appStore.getState(); + const draft = state.issueCommentDraft; + const canSubmit = + Boolean(draft.content.trim() || draft.screenshots.length || draft.files.length) && !state.isCreatingIssueComment; + + return ` +
+
+ #${issue.number} ${escapeHtml(issue.title)} + ${escapeHtml(issue.state)} +
+ +
+ + +
+
+ Screenshots + +
+ ${renderScreenshotList(draft.screenshots, "comment")} +
+ + + ${renderAttachmentList( + draft.files.map((file) => file.name), + "No files selected." + )} + + +
+
+ `; +} + +function renderTargetIssues(): string { + const state = appStore.getState(); + const selectedIssue = state.targetIssues.find((issue) => issue.number === state.selectedIssueNumber) ?? null; + + return ` +
+
+ Issues + +
+ ${state.isLoadingTargetIssues && !state.targetIssues.length ? `
Loading issues...
` : renderIssueRows(state.targetIssues, state.selectedIssueNumber)} + ${selectedIssue ? renderIssueCommentForm(selectedIssue) : ""} +
+ `; +} + function renderAddIssue(): string { const state = appStore.getState(); const knownUrl = getActiveKnownUrl(); @@ -357,7 +446,7 @@ function renderAddIssue(): string { ${state.isCapturingScreenshot ? "Taking..." : "Take snapshot"}
- ${renderScreenshotList(draft.screenshots)} + ${renderScreenshotList(draft.screenshots, "issue")}