Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ tagged `vX.Y.Z`.

## Unreleased

### Added

- **Recent projects widget.** Lists the folders you worked in lately — git repositories under the
folders you choose, plus, if you tick them, Claude Code, Codex, VS Code, Cursor, JetBrains IDEs,
zoxide, tmux and Herdr — and opens one with a tap in Finder, a terminal, your editor (a
JetBrains IDE included) or Herdr (the pane already in that folder, else a new one, with Herdr's
terminal brought to the front), or starts Claude Code or Codex in a new Herdr pane or tmux
window on it; a long press offers the other installed applications, and can make one the
project's own for every later tap. Without one, the files at a project's root can suggest the
right IDE (a `.sln` for Rider, a `Cargo.toml` for RustRover…). Only folder paths, dates and
the names at a project's root are read, never a conversation or a file's contents.

### Fixed

- **The clipboard widget masks one-time codes.** A six-digit code copied from a text message or
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ limits, and how to report a problem: **[SECURITY.md](SECURITY.md)**.
## Credits and trademarks

Fremkit is written by [usul](https://github.com/fdussert), with
[FlorianBruniaux](https://github.com/FlorianBruniaux) and [mcouzinet](https://github.com/mcouzinet).
[FlorianBruniaux](https://github.com/FlorianBruniaux), [mcouzinet](https://github.com/mcouzinet) and
[LivioGama](https://github.com/LivioGama).
The widgets and themes on the registry name their own authors on their cards. The admin's
**Settings → About** lists the same people, from `ui/src/shared/credits.ts`.

Expand Down
18 changes: 18 additions & 0 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { createShortcutsProvider } from './providers/shortcuts.js'
import { createServiceStatusProvider } from './providers/service-status.js'
import { createSystemProvider } from './providers/system.js'
import { createDiskMapProvider } from './providers/disk-map.js'
import { createRecentProjectsProvider, MEMORY_FILE as RECENT_PROJECTS_FILE, RECENT_PROJECTS_CHANNEL, RECENT_PROJECTS_WIDGET } from './providers/recent-projects/index.js'
import { BrightnessService } from './brightness/service.js'
import { createBrightnessProvider, BRIGHTNESS_INTERVAL_MS } from './brightness/provider.js'
import { brightnessRoutes } from './brightness/routes.js'
Expand Down Expand Up @@ -284,6 +285,8 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
const config = store.get()
return instanceInScope(config, commandScope(ctx, screenOfDevice), instanceId) ? findInstance(config, instanceId) : null
}
/** Kept for the diagnostics, which report its sources' counts. Null in demo mode. */
let recentProjects: ReturnType<typeof createRecentProjectsProvider> | null = null
/** Every real provider: the Mac, the accounts, the helper's reports. Never called in demo mode. */
function registerRealProviders(): void {
for (const p of opts.providers ?? []) registry.register(p)
Expand All @@ -309,6 +312,13 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
// Registered here, not in providers/index.ts, because that is where the config store lives.
registry.register(createShortcutsProvider(undefined, instances))
registry.register(createServiceStatusProvider({}, instances))
// Reads what every shown tile ticked, so a source no tile asked for is never read.
recentProjects = createRecentProjectsProvider({
instances: () => findInstances(store.get(), RECENT_PROJECTS_WIDGET),
memoryFile: join(opts.dataDir, RECENT_PROJECTS_FILE),
onChange: () => registry.refresh(RECENT_PROJECTS_CHANNEL),
})
registry.register(recentProjects)
// A paired device may set only its own screen's brightness: see mayCommandBrightness. Read
// at command time, so a device moved to another screen (or unpaired) is judged as it is now.
registry.register(createBrightnessProvider(brightness, brightnessChanged, (id) => deviceService.deviceScreenOf(id)))
Expand Down Expand Up @@ -375,7 +385,14 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
// How each provider's last poll went, for the editor's widget health (providers/health.ts).
const stopHealth = publishHealth(registry, (channel, data) => hub.broadcast(channel, data))
let showAccountEmail = store.get().privacy.showAccountEmail
// A tile that ticks a source or adds a git root sees it now, not on the next minute's poll.
let recentProjectsWants = JSON.stringify(findInstances(store.get(), RECENT_PROJECTS_WIDGET))
store.onChange((cfg) => {
const wants = JSON.stringify(findInstances(cfg, RECENT_PROJECTS_WIDGET))
if (wants !== recentProjectsWants) {
recentProjectsWants = wants
registry.refresh(RECENT_PROJECTS_CHANNEL)
}
setServerLocale(cfg.locale)
if (cfg.privacy.showAccountEmail !== showAccountEmail) {
showAccountEmail = cfg.privacy.showAccountEmail
Expand Down Expand Up @@ -564,6 +581,7 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
channelFor: (connection) => connections.channelFor(connection),
secretsFor: (connection) => connections.secretsFor(connection),
channels: () => registry.status(),
recentProjects: () => recentProjects?.snapshot()?.sources ?? null,
devices: () => devices.list(),
remoteAccess: () => devices.enabled,
accessToken: opts.accessToken,
Expand Down
56 changes: 56 additions & 0 deletions server/src/demo/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,65 @@ export function createDemoProviders(opts: DemoProviderOptions): Provider[] {
rtkProvider(now),
{ channel: 'shortcuts', commands: { open: ACTED } },
serviceStatusProvider(now, opts.instances ?? ((id) => findInstance(opts.config(), id))),
recentProjectsProvider(now),
]
}

/** Invented folders under an invented home, touched over the last few days. */
function recentProjectsProvider(now: () => number): Provider {
const HOUR = 3_600_000
const rows: { name: string; parent: string; ago: number; sources: string[]; suggested?: string }[] = [
{ name: 'example-api', parent: '~/Dev', ago: 0.3, sources: ['git', 'claude', 'herdr'], suggested: 'jetbrains-rider' },
{ name: 'dashboard-web', parent: '~/Dev', ago: 2, sources: ['git', 'vscode'] },
{ name: 'mobile-app', parent: '~/Dev/clients/acme', ago: 5, sources: ['git', 'claude'], suggested: 'xcode' },
{ name: 'infra', parent: '~/Dev', ago: 26, sources: ['git', 'herdr'], suggested: 'jetbrains-goland' },
{ name: 'design-system', parent: '~/Dev/clients/acme', ago: 50, sources: ['git', 'vscode', 'claude'] },
{ name: 'notes', parent: '~/Documents', ago: 74, sources: ['claude'] },
{ name: 'blog', parent: '~/Dev/personal', ago: 120, sources: ['git'] },
]
const pathOf = (r: { parent: string; name: string }) => `${r.parent.replace('~', '/Users/demo')}/${r.name}`
// Openers set during the demo, in memory; the dashboard one starts with one of its own.
const openers = new Map<string, string>([[pathOf(rows[1]), 'zed']])
return {
channel: 'recent-projects',
intervalMs: 60_000,
poll: async () => {
const t = now()
const projects = rows.map((r) => {
const path = pathOf(r)
const opener = openers.get(path)
return {
path,
name: r.name,
parent: r.parent,
seenAt: Math.round(t - r.ago * HOUR),
sources: r.sources,
...(r.sources.includes('git') ? { gitRoots: ['~/Dev'] } : {}),
...(opener ? { opener } : r.suggested ? { suggested: r.suggested } : {}),
}
})
const ids = ['git', 'claude', 'codex', 'vscode', 'cursor', 'jetbrains', 'zoxide', 'tmux', 'herdr']
const on = new Set(['git', 'claude', 'vscode', 'herdr'])
return {
projects,
sources: ids.map((id) => ({ id, enabled: on.has(id), available: on.has(id), count: projects.filter((p) => p.sources.includes(id)).length })),
apps: ['finder', 'terminal', 'vscode', 'zed', 'xcode', 'herdr', 'herdr-claude', 'herdr-codex', 'jetbrains-rider', 'jetbrains-goland'],
updatedAt: t,
}
},
commands: {
open: ACTED,
setOpener: async (payload: unknown) => {
const { path, app } = (payload ?? {}) as { path?: unknown; app?: unknown }
if (typeof path !== 'string' || !rows.some((r) => pathOf(r) === path)) return { ok: false, error: 'unknown-project' }
if (typeof app === 'string') openers.set(path, app)
else openers.delete(path)
return { ok: true }
},
},
}
}

function systemProvider(now: () => number, startedAt: number): Provider {
const total = 32 * GB
return {
Expand Down
4 changes: 3 additions & 1 deletion server/src/demo/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const DEMO_SETTINGS: Record<string, Record<string, unknown>> = {
{ name: 'Backup NAS', kind: 'ping', url: '192.0.2.10' },
],
},
'recent-projects': { source_git: true, source_claude: true, source_vscode: true, source_herdr: true, gitRoots: [{ path: '~/Dev' }] },
shortcuts: {
buttons: [
{ label: 'Mail', kind: 'app', target: 'Mail', icon: '✉️' },
Expand Down Expand Up @@ -94,7 +95,8 @@ const PAGES: { id: string; name: string; items: (Placement & { widgetId: string
{ instanceId: 'processes-1', widgetId: 'processes', x: 24, y: 0, w: 16, h: 8 },
{ instanceId: 'clipboard-1', widgetId: 'clipboard', x: 24, y: 8, w: 16, h: 8 },
{ instanceId: 'shortcuts-1', widgetId: 'shortcuts', x: 40, y: 0, w: 24, h: 8 },
{ instanceId: 'clock-2', widgetId: 'clock', x: 40, y: 8, w: 24, h: 8 },
{ instanceId: 'clock-2', widgetId: 'clock', x: 40, y: 8, w: 12, h: 8 },
{ instanceId: 'recent-projects-1', widgetId: 'recent-projects', x: 52, y: 8, w: 12, h: 8 },
],
},
]
Expand Down
16 changes: 16 additions & 0 deletions server/src/diagnostics/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export interface DiagnosticsFacts {
/** Channels that are watched or have polled; the rest are only counted. */
providers: { channel: string; watched: boolean; state: string }[]
idleProviders: number
/**
* The recent-projects sources a tile ticked: an id, whether it is installed, how many projects
* it named, and its error code. Counts only — never a path.
*/
recentProjects?: { id: string; available: boolean; count: number; error?: string }[]
devices: { paired: number; remoteAccess: boolean }
log: LogSource | null
}
Expand Down Expand Up @@ -94,6 +99,13 @@ export function renderReport(f: DiagnosticsFacts): string {
if (f.idleProviders > 0) out.push('', `${f.idleProviders} other channels idle, never polled.`)
out.push('')

if (f.recentProjects?.length) {
out.push('### Recent projects sources', '')
out.push('| Source | Installed | Projects | Error |', '|---|---|---|---|')
for (const r of f.recentProjects) out.push(`| ${r.id} | ${r.available ? 'yes' : 'no'} | ${r.count} | ${r.error ?? '–'} |`)
out.push('')
}

if (f.log) {
const where = f.log.kind === 'file' ? 'server.log' : 'since this server started'
out.push(`### Server log (last ${f.log.lines.length} lines, ${where}, redacted)`, '')
Expand Down Expand Up @@ -211,6 +223,8 @@ export interface DiagnosticsDeps {
channelFor: (connection: Connection) => string
secretsFor: (connection: Connection) => Promise<Record<string, string>>
channels: () => ChannelStatus[]
/** The recent-projects provider's last source statuses, or null before its first poll. */
recentProjects?: () => { id: string; enabled: boolean; available: boolean; count: number; error?: string }[] | null
devices: () => { name: string }[]
remoteAccess: () => boolean
accessToken: string | null
Expand Down Expand Up @@ -359,6 +373,8 @@ export async function buildDiagnostics(deps: DiagnosticsDeps): Promise<string> {
connections,
providers,
idleProviders: allChannels.length - active.length,
recentProjects: deps.recentProjects?.()?.filter((r) => r.enabled)
.map((r) => ({ id: r.id, available: r.available, count: r.count, ...(r.error ? { error: r.error } : {}) })),
devices: { paired: pairedDevices.length, remoteAccess: deps.remoteAccess() },
log: deps.log ? await deps.log(RAW_LOG_LINES).then(compactLog, () => null) : null,
}
Expand Down
6 changes: 3 additions & 3 deletions server/src/providers/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { execFile } from 'node:child_process'
* arguments are passed as an array and never re-parsed, so nothing a caller supplies can be read
* as shell syntax.
*/
export type Exec = (file: string, args: string[]) => Promise<string>
export type Exec = (file: string, args: string[], opts?: { timeoutMs?: number }) => Promise<string>

export const execCommand: Exec = (file, args) =>
export const execCommand: Exec = (file, args, opts) =>
new Promise((resolve, reject) => {
execFile(file, args, { timeout: 5000, maxBuffer: 4 * 1024 * 1024 }, (err, stdout, stderr) => {
execFile(file, args, { timeout: opts?.timeoutMs ?? 5000, maxBuffer: 4 * 1024 * 1024 }, (err, stdout, stderr) => {
if (err) reject(new Error(stderr.trim() || err.message))
else resolve(stdout)
})
Expand Down
Loading
Loading