/ components / EffortIndicator.ts
EffortIndicator.ts
 1  import {
 2    EFFORT_HIGH,
 3    EFFORT_LOW,
 4    EFFORT_MAX,
 5    EFFORT_MEDIUM,
 6  } from '../constants/figures.js'
 7  import {
 8    type EffortLevel,
 9    type EffortValue,
10    getDisplayedEffortLevel,
11    modelSupportsEffort,
12  } from '../utils/effort.js'
13  
14  /**
15   * Build the text for the effort-changed notification, e.g. "◐ medium · /effort".
16   * Returns undefined if the model doesn't support effort.
17   */
18  export function getEffortNotificationText(
19    effortValue: EffortValue | undefined,
20    model: string,
21  ): string | undefined {
22    if (!modelSupportsEffort(model)) return undefined
23    const level = getDisplayedEffortLevel(model, effortValue)
24    return `${effortLevelToSymbol(level)} ${level} · /effort`
25  }
26  
27  export function effortLevelToSymbol(level: EffortLevel): string {
28    switch (level) {
29      case 'low':
30        return EFFORT_LOW
31      case 'medium':
32        return EFFORT_MEDIUM
33      case 'high':
34        return EFFORT_HIGH
35      case 'max':
36        return EFFORT_MAX
37      default:
38        // Defensive: level can originate from remote config. If an unknown
39        // value slips through, render the high symbol rather than undefined.
40        return EFFORT_HIGH
41    }
42  }