diff --git a/.github/workflows/stale-assignments.yml b/.github/workflows/stale-assignments.yml index d418958e9..06451fc1c 100644 --- a/.github/workflows/stale-assignments.yml +++ b/.github/workflows/stale-assignments.yml @@ -24,6 +24,10 @@ # - 21 days total -> unassign + add help wanted # - Issues with lifecycle/frozen are exempt # +# "Activity" = last human comment or the assignment event -- deliberately NOT +# issue.updated_at, which is bumped by the bot's own comment and label edits and +# would reset the clock every run (so the unassign threshold was never reached). +# # Security: only uses numeric IDs and login names from the GitHub API. # No untrusted string input is interpolated into shell commands. @@ -83,18 +87,51 @@ jobs: continue; } - const updatedAt = new Date(issue.updated_at); - const daysSinceUpdate = Math.floor((now - updatedAt) / (1000 * 60 * 60 * 24)); const assigneeLogins = issue.assignees.map(a => a.login); + // Measure inactivity from the last *human* activity, NOT issue.updated_at. + // updated_at is bumped by anything that touches the issue -- including this + // bot's own warning comment and label edits -- which reset the clock every + // run, so the unassign threshold was never reached. Take the most recent of: + // last non-bot comment, the assignment event for a current assignee (so a + // freshly assigned issue is not instantly stale), and issue creation time. + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + per_page: 100, + }); + + let lastActivity = new Date(issue.created_at); + for (const c of comments) { + if (c.user.login === 'github-actions[bot]') continue; + const t = new Date(c.created_at); + if (t > lastActivity) lastActivity = t; + } + + const events = await github.paginate(github.rest.issues.listEvents, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + per_page: 100, + }); + for (const e of events) { + if (e.event === 'assigned' && e.assignee && assigneeLogins.includes(e.assignee.login)) { + const t = new Date(e.created_at); + if (t > lastActivity) lastActivity = t; + } + } + + const daysSinceActivity = Math.floor((now - lastActivity) / (1000 * 60 * 60 * 24)); + // 21+ days -> unassign and add help wanted - if (daysSinceUpdate >= UNASSIGN_DAYS) { + if (daysSinceActivity >= UNASSIGN_DAYS) { const names = assigneeLogins.map(l => `@${l}`).join(', '); - console.log(`#${issue.number}: unassigning ${names} (${daysSinceUpdate} days)`); + console.log(`#${issue.number}: unassigning ${names} (${daysSinceActivity} days)`); const unassignMsg = [ - `Removing assignment from ${names} after ${daysSinceUpdate} days of inactivity`, + `Removing assignment from ${names} after ${daysSinceActivity} days of inactivity`, '(per the [assignment policy](../blob/main/CONTRIBUTING.rst#issue-assignment-policy)).', '', 'Feel free to comment if you want to pick this back up or if someone else wants to take it.', @@ -127,15 +164,8 @@ jobs: } // 14+ days -> warn - if (daysSinceUpdate >= WARN_DAYS) { - // Check if we already warned (avoid spamming) - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue.number, - per_page: 5, - }); - + if (daysSinceActivity >= WARN_DAYS) { + // Avoid spamming: skip if we already warned within the last 10 days. const recentWarn = comments.some(c => c.user.login === 'github-actions[bot]' && c.body.includes('assignment policy') && @@ -149,10 +179,10 @@ jobs: const names = assigneeLogins.map(l => `@${l}`).join(', '); - console.log(`#${issue.number}: warning ${names} (${daysSinceUpdate} days)`); + console.log(`#${issue.number}: warning ${names} (${daysSinceActivity} days)`); const warnMsg = [ - `${names}, this issue has been inactive for ${daysSinceUpdate} days.`, + `${names}, this issue has been inactive for ${daysSinceActivity} days.`, 'Are you still working on it? Drop a comment to let us know.', '', 'If there is no update within 7 days, the assignment will be removed', diff --git a/README.md b/README.md index 1e90250aa..b4b659b3d 100644 --- a/README.md +++ b/README.md @@ -257,4 +257,4 @@ Apache Burr is released under the Apache 2.0 License. See [LICENSE](https://gith ## Contributing We're very supportive of changes by new contributors, big or small! Make sure to discuss potential changes by creating an issue or commenting on an existing one before opening a pull request. Good first contributions include creating an example or an integration with your favorite Python library! - To contribute, checkout our [contributing guidelines](https://github.com/apache/burr/blob/main/CONTRIBUTING.rst), our [developer setup guide](https://github.com/apache/burr/blob/main/developer_setup.md), and our [Code of Conduct](https://github.com/apache/burr/blob/main/CODE_OF_CONDUCT.md). + To contribute, checkout our [contributing guidelines](https://github.com/apache/burr/blob/main/CONTRIBUTING.rst), our [developer setup guide](https://github.com/apache/burr/blob/main/docs/contributing/setup.rst), and the [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html). diff --git a/telemetry/ui/src/App.tsx b/telemetry/ui/src/App.tsx index 121337ae3..d49900c49 100644 --- a/telemetry/ui/src/App.tsx +++ b/telemetry/ui/src/App.tsx @@ -31,6 +31,7 @@ import { StreamingChatbotWithTelemetry } from './examples/StreamingChatbot'; import { AdminView } from './components/routes/AdminView'; import { AnnotationsViewContainer } from './components/routes/app/AnnotationsView'; import { DeepResearcherWithTelemetry } from './examples/DeepResearcher'; +import { useTheme } from './hooks/useTheme'; /** * Basic application. We have an AppContainer -- this has a breadcrumb and a sidebar. @@ -48,6 +49,9 @@ import { DeepResearcherWithTelemetry } from './examples/DeepResearcher'; * @returns A rendered application object */ const App = () => { + // Initialize theme at the app root so the `dark` class is applied on load + // (respects system preference, falls back to stored manual override). + useTheme(); return ( diff --git a/telemetry/ui/src/components/common/ThemeToggle.tsx b/telemetry/ui/src/components/common/ThemeToggle.tsx new file mode 100644 index 000000000..569ce9061 --- /dev/null +++ b/telemetry/ui/src/components/common/ThemeToggle.tsx @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { MoonIcon, SunIcon } from '@heroicons/react/24/outline'; +import { classNames } from '../../utils/tailwind'; +import { useTheme } from '../../hooks/useTheme'; + +/** + * A simple sun/moon button that toggles between light and dark mode. + * Replaces the previously broken radio toggle referenced in issue #209. + */ +export const ThemeToggle = (props: { showLabel?: boolean }) => { + const { isDark, toggle } = useTheme(); + const Icon = isDark ? SunIcon : MoonIcon; + const label = isDark ? 'Switch to light mode' : 'Switch to dark mode'; + return ( + + ); +}; diff --git a/telemetry/ui/src/components/nav/appcontainer.tsx b/telemetry/ui/src/components/nav/appcontainer.tsx index 35c217e5f..5e4969b7d 100644 --- a/telemetry/ui/src/components/nav/appcontainer.tsx +++ b/telemetry/ui/src/components/nav/appcontainer.tsx @@ -37,6 +37,7 @@ import { classNames } from '../../utils/tailwind'; import React from 'react'; import { DefaultService } from '../../api'; import { useQuery } from 'react-query'; +import { ThemeToggle } from '../common/ThemeToggle'; // Define your GitHub logo SVG as a React component const GithubLogo = () => ( @@ -64,8 +65,8 @@ const ToggleOpenButton = (props: { open: boolean; toggleSidebar: () => void }) = return (