mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-19 10:43:08 +00:00
Merge remote-tracking branch 'upstream/v0.15.0rc' into feat/add-zai-usage-tracking
# Conflicts: # apps/ui/src/components/usage-popover.tsx # apps/ui/src/components/views/board-view/mobile-usage-bar.tsx
This commit is contained in:
@@ -7,7 +7,6 @@ import { createLogger } from '@automaker/utils/logger';
|
||||
// Note: setItem/getItem moved to ./utils/theme-utils.ts
|
||||
import { UI_SANS_FONT_OPTIONS, UI_MONO_FONT_OPTIONS } from '@/config/ui-font-options';
|
||||
import type {
|
||||
Feature as BaseFeature,
|
||||
FeatureImagePath,
|
||||
FeatureTextFilePath,
|
||||
ModelAlias,
|
||||
@@ -15,25 +14,11 @@ import type {
|
||||
ThinkingLevel,
|
||||
ReasoningEffort,
|
||||
ModelProvider,
|
||||
CursorModelId,
|
||||
CodexModelId,
|
||||
OpencodeModelId,
|
||||
GeminiModelId,
|
||||
CopilotModelId,
|
||||
PhaseModelConfig,
|
||||
PhaseModelKey,
|
||||
PhaseModelEntry,
|
||||
MCPServerConfig,
|
||||
FeatureStatusWithPipeline,
|
||||
PipelineConfig,
|
||||
PipelineStep,
|
||||
PromptCustomization,
|
||||
ModelDefinition,
|
||||
ServerLogLevel,
|
||||
EventHook,
|
||||
ClaudeApiProfile,
|
||||
ClaudeCompatibleProvider,
|
||||
SidebarStyle,
|
||||
ParsedTask,
|
||||
PlanSpec,
|
||||
} from '@automaker/types';
|
||||
@@ -2153,7 +2138,7 @@ export const useAppStore = create<AppState & AppActions>()((set, get) => ({
|
||||
const updateSizes = (layout: TerminalPanelContent): TerminalPanelContent => {
|
||||
if (layout.type === 'split') {
|
||||
// Find matching panels and update sizes
|
||||
const updatedPanels = layout.panels.map((panel, index) => {
|
||||
const updatedPanels = layout.panels.map((panel, _index) => {
|
||||
// Generate key for this panel
|
||||
const panelKey =
|
||||
panel.type === 'split'
|
||||
|
||||
@@ -155,7 +155,6 @@ export const useTestRunnersStore = create<TestRunnersState & TestRunnersActions>
|
||||
const finishedAt = new Date().toISOString();
|
||||
|
||||
// Remove from active sessions since it's no longer running
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { [session.worktreePath]: _, ...remainingActive } = state.activeSessionByWorktree;
|
||||
|
||||
return {
|
||||
@@ -202,7 +201,6 @@ export const useTestRunnersStore = create<TestRunnersState & TestRunnersActions>
|
||||
const session = state.sessions[sessionId];
|
||||
if (!session) return state;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { [sessionId]: _, ...remainingSessions } = state.sessions;
|
||||
|
||||
// Remove from active if this was the active session
|
||||
@@ -231,7 +229,6 @@ export const useTestRunnersStore = create<TestRunnersState & TestRunnersActions>
|
||||
});
|
||||
|
||||
// Remove from active
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { [worktreePath]: _, ...remainingActive } = state.activeSessionByWorktree;
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,8 +2,6 @@ import type { Project, TrashedProject } from '@/lib/electron';
|
||||
import type {
|
||||
ModelAlias,
|
||||
PlanningMode,
|
||||
ThinkingLevel,
|
||||
ReasoningEffort,
|
||||
ModelProvider,
|
||||
CursorModelId,
|
||||
CodexModelId,
|
||||
@@ -33,7 +31,7 @@ import type {
|
||||
BackgroundSettings,
|
||||
} from './ui-types';
|
||||
import type { ApiKeys } from './settings-types';
|
||||
import type { ChatMessage, ChatSession, FeatureImage } from './chat-types';
|
||||
import type { ChatMessage, ChatSession } from './chat-types';
|
||||
import type { TerminalState, TerminalPanelContent, PersistedTerminalState } from './terminal-types';
|
||||
import type { Feature, ProjectAnalysis } from './project-types';
|
||||
import type { ClaudeUsage, CodexUsage, ZaiUsage } from './usage-types';
|
||||
|
||||
@@ -1,5 +1,64 @@
|
||||
import type { ClaudeUsage } from '../types/usage-types';
|
||||
|
||||
/**
|
||||
* Calculate the expected weekly usage percentage based on how far through the week we are.
|
||||
* Claude's weekly usage resets every Thursday. Given the reset time (when the NEXT reset occurs),
|
||||
* we can determine how much of the week has elapsed and therefore what percentage of the budget
|
||||
* should have been used if usage were evenly distributed.
|
||||
*
|
||||
* @param weeklyResetTime - ISO date string for when the weekly usage next resets
|
||||
* @returns The expected usage percentage (0-100), or null if the reset time is invalid
|
||||
*/
|
||||
export function getExpectedWeeklyPacePercentage(
|
||||
weeklyResetTime: string | undefined
|
||||
): number | null {
|
||||
if (!weeklyResetTime) return null;
|
||||
|
||||
try {
|
||||
const resetDate = new Date(weeklyResetTime);
|
||||
if (isNaN(resetDate.getTime())) return null;
|
||||
|
||||
const now = new Date();
|
||||
const WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
|
||||
// The week started 7 days before the reset
|
||||
const weekStartDate = new Date(resetDate.getTime() - WEEK_MS);
|
||||
|
||||
// How far through the week are we?
|
||||
const elapsed = now.getTime() - weekStartDate.getTime();
|
||||
const fractionElapsed = elapsed / WEEK_MS;
|
||||
|
||||
// Clamp to 0-1 range
|
||||
const clamped = Math.max(0, Math.min(1, fractionElapsed));
|
||||
|
||||
return clamped * 100;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human-readable label for the pace status (ahead or behind expected usage).
|
||||
*
|
||||
* @param actualPercentage - The actual usage percentage (0-100)
|
||||
* @param expectedPercentage - The expected usage percentage (0-100)
|
||||
* @returns A string like "5% ahead of pace" or "10% behind pace", or null
|
||||
*/
|
||||
export function getPaceStatusLabel(
|
||||
actualPercentage: number,
|
||||
expectedPercentage: number | null
|
||||
): string | null {
|
||||
if (expectedPercentage === null) return null;
|
||||
|
||||
const diff = Math.round(actualPercentage - expectedPercentage);
|
||||
|
||||
if (diff === 0) return 'On pace';
|
||||
// Using more than expected = behind pace (bad)
|
||||
if (diff > 0) return `${Math.abs(diff)}% behind pace`;
|
||||
// Using less than expected = ahead of pace (good)
|
||||
return `${Math.abs(diff)}% ahead of pace`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Claude usage is at its limit (any of: session >= 100%, weekly >= 100%, OR cost >= limit)
|
||||
* Returns true if any limit is reached, meaning auto mode should pause feature pickup.
|
||||
|
||||
Reference in New Issue
Block a user