fix: five defects found while rewriting the docs (UF-061 to UF-065)

- Key messages named a Settings > API Keys tab that does not exist; they
  now point at Settings > Models (UF-061).
- The connector suggestion looked for vault.db, which never exists; it
  now checks the vault for a connector entry (UF-062).
- /config and /preferences were registered with a leading slash and
  never matched (UF-063).
- Pins and documents were written under ~/.waggle whatever the data
  directory; they now use the server's data directory (UF-064).
- The Windows uninstaller named a Data & Privacy page that does not
  exist (UF-065).
This commit is contained in:
shumeiko.it
2026-11-01 02:08:57 +01:00
parent 9806afbced
commit 74200d46e8
14 changed files with 171 additions and 40 deletions

View File

@@ -1370,6 +1370,7 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
workspaceManager: wsManager,
memory,
waggleDb,
vault,
};
/** Emit a ProactiveMessage through the delivery router pipeline. */
@@ -2185,7 +2186,7 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
return null;
}
function markAnthropicProxyDegraded(detail = 'Built-in Anthropic proxy (API key invalid or expired, update in Settings > API Keys)'): void {
function markAnthropicProxyDegraded(detail = 'Built-in Anthropic proxy (API key invalid or expired, update in Settings > Models)'): void {
server.agentState.llmProvider.health = 'degraded';
server.agentState.llmProvider.detail = detail;
}
@@ -2356,7 +2357,7 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
const keyValid = freshAnthropicValidation();
if (keyValid === false) {
llm.health = 'degraded';
llm.detail = 'Built-in Anthropic proxy (API key invalid or expired, update in Settings > API Keys)';
llm.detail = 'Built-in Anthropic proxy (API key invalid or expired, update in Settings > Models)';
markAnthropicProxyDegraded(llm.detail);
} else if (keyValid === null) {
validateAnthropicKeyInBackground();

View File

@@ -36,6 +36,8 @@ export interface ProactiveContext {
memory: MemoryStore;
/** waggle.db, which holds awareness items. */
waggleDb: import('@waggle/core').WaggleDB;
/** Connector credentials live in the vault under `connector:<id>`. */
vault?: Pick<import('@waggle/core').VaultStore, 'list'>;
}
// ── Helpers ────────────────────────────────────────────────────────────
@@ -276,8 +278,7 @@ export async function suggestCapabilities(ctx: ProactiveContext): Promise<Proact
if (totalFrames > 50) {
const hasConnectors = (() => {
try {
const vaultPath = path.join(ctx.dataDir, 'vault.db');
return fs.existsSync(vaultPath);
return ctx.vault?.list().some((entry) => entry.name.startsWith('connector:')) ?? false;
} catch {
return false;
}

View File

@@ -907,7 +907,7 @@ async function forwardCompatibleProvider(
if (apiKeys.length === 0) {
return reply.status(500).send({
error: {
message: `No ${route.providerId} API key configured. Add one in Settings > API Keys.`,
message: `No ${route.providerId} API key configured. Add one in Settings > Models.`,
},
});
}
@@ -1117,14 +1117,14 @@ export const anthropicProxyRoutes: FastifyPluginAsync = async (server) => {
if (route.providerId === 'anthropic' && !getAnthropicKey(server)) {
releaseProxySpend(server, claimProxySpendHandoff(server, request, body));
return reply.status(500).send({
error: { message: 'No Anthropic API key configured. Add one in Settings > API Keys.' },
error: { message: 'No Anthropic API key configured. Add one in Settings > Models.' },
});
}
if (route.providerId !== 'anthropic' && getProviderApiKeys(route.providerId, server.vault).length === 0) {
releaseProxySpend(server, claimProxySpendHandoff(server, request, body));
return reply.status(500).send({
error: {
message: `No ${route.providerId} API key configured. Add one in Settings > API Keys.`,
message: `No ${route.providerId} API key configured. Add one in Settings > Models.`,
},
});
}

View File

@@ -1748,7 +1748,7 @@ ${wsConfig?.templateId ? `- Workspace template: ${wsConfig.templateId} — tailo
reroutedMessage = rerouted;
} else if (cmdResult.startsWith(AGENT_LOOP_REROUTE_PREFIX) && !litellmAvailable) {
const cmdName = message.trim().split(/\s+/)[0];
const friendlyError = `**${cmdName} requires AI.** This command needs a working LLM connection.\n\nConfigure an API key in Settings > API Keys, then try again.`;
const friendlyError = `**${cmdName} requires AI.** This command needs a working LLM connection.\n\nConfigure an API key in Settings > Models, then try again.`;
const words = friendlyError.split(' ');
for (const word of words) {
if (turnSignal.aborted) return;
@@ -1794,7 +1794,7 @@ ${wsConfig?.templateId ? `- Workspace template: ${wsConfig.templateId} — tailo
if (shouldEchoMode) {
// Setup-required mode — respond without pretending the user's input
// was answered. The raw turn is still persisted for continuity.
const echoResponse = '**No AI model is ready.**\n\nConfigure a provider key in Settings > API Keys, or install and verify a local model in Settings > Models, then try again.';
const echoResponse = '**No AI model is ready.**\n\nConfigure a provider key in Settings > Models, or install and verify a local model in Settings > Models, then try again.';
const words = echoResponse.split(' ');
for (const word of words) {
if (turnSignal.aborted) return;
@@ -3471,7 +3471,7 @@ ${wsConfig?.templateId ? `- Workspace template: ${wsConfig.templateId} — tailo
if (err.message.includes('ECONNREFUSED')) {
errorMessage = 'Could not reach the AI model. Check that your API key is configured in Settings.';
} else if (err.message.includes('401') || err.message.includes('Unauthorized')) {
errorMessage = 'API key is invalid or expired. Update it in Settings > API Keys.';
errorMessage = 'API key is invalid or expired. Update it in Settings > Models.';
} else if (err.message.includes('timeout') || err.message.includes('ETIMEDOUT')) {
errorMessage = 'The request timed out. The model may be overloaded. Try again in a moment.';
} else if (err.message.includes('context_length') || err.message.includes('too many tokens')) {

View File

@@ -6,7 +6,7 @@
* POST /api/workspaces/:id/documents — register a new document version
* GET /api/workspaces/:id/documents/:name/versions — list versions of a document
*
* Versions are stored in ~/.waggle/workspaces/{id}/documents.json.
* Versions are stored in <dataDir>/workspaces/{id}/documents.json.
* Part of Wave 7 — Professional & Vertical Features.
*/
@@ -33,13 +33,13 @@ interface DocumentsRegistry {
}
/** Resolve the documents.json path for a workspace. */
function documentsFilePath(workspaceId: string): string {
return path.join(os.homedir(), '.waggle', 'workspaces', workspaceId, 'documents.json');
function documentsFilePath(dataDir: string, workspaceId: string): string {
return path.join(dataDir, 'workspaces', workspaceId, 'documents.json');
}
/** Read document registry from disk. Returns empty registry if file doesn't exist. */
function readRegistry(workspaceId: string): DocumentsRegistry {
const filePath = documentsFilePath(workspaceId);
function readRegistry(dataDir: string, workspaceId: string): DocumentsRegistry {
const filePath = documentsFilePath(dataDir, workspaceId);
try {
if (fs.existsSync(filePath)) {
const raw = fs.readFileSync(filePath, 'utf-8');
@@ -52,8 +52,8 @@ function readRegistry(workspaceId: string): DocumentsRegistry {
}
/** Write document registry to disk. Creates directory if needed. */
function writeRegistry(workspaceId: string, registry: DocumentsRegistry): void {
const filePath = documentsFilePath(workspaceId);
function writeRegistry(dataDir: string, workspaceId: string, registry: DocumentsRegistry): void {
const filePath = documentsFilePath(dataDir, workspaceId);
const dir = path.dirname(filePath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
@@ -62,13 +62,15 @@ function writeRegistry(workspaceId: string, registry: DocumentsRegistry): void {
}
export const documentRoutes: FastifyPluginAsync = async (server) => {
const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle');
// GET /api/workspaces/:id/documents — list all tracked documents
server.get<{
Params: { id: string };
}>('/api/workspaces/:id/documents', async (request) => {
const { id } = request.params;
assertSafeSegment(id, 'id');
const registry = readRegistry(id);
const registry = readRegistry(dataDir, id);
return {
documents: registry.documents.map(doc => ({
name: doc.name,
@@ -96,7 +98,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
}
assertSafeSegment(name, 'name');
const registry = readRegistry(id);
const registry = readRegistry(dataDir, id);
let doc = registry.documents.find(d => d.name === name);
if (!doc) {
@@ -116,7 +118,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
};
doc.versions.push(version);
writeRegistry(id, registry);
writeRegistry(dataDir, id, registry);
return reply.status(201).send({ document: name, version });
});
@@ -128,7 +130,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
const { id, name } = request.params;
assertSafeSegment(id, 'id');
assertSafeSegment(name, 'name');
const registry = readRegistry(id);
const registry = readRegistry(dataDir, id);
const doc = registry.documents.find(d => d.name === name);
if (!doc) {

View File

@@ -6,7 +6,7 @@
* POST /api/workspaces/:id/pins — add pin
* DELETE /api/workspaces/:id/pins/:pinId — remove pin
*
* Pins are stored in a JSON file at ~/.waggle/workspaces/{id}/pins.json.
* Pins are stored in a JSON file at <dataDir>/workspaces/{id}/pins.json.
* Part of Wave 5 — Visibility & Polish.
*/
@@ -28,13 +28,13 @@ export interface PinnedItem {
}
/** Resolve the pins.json path for a workspace. */
function pinsFilePath(workspaceId: string): string {
return path.join(os.homedir(), '.waggle', 'workspaces', workspaceId, 'pins.json');
function pinsFilePath(dataDir: string, workspaceId: string): string {
return path.join(dataDir, 'workspaces', workspaceId, 'pins.json');
}
/** Read pins from disk. Returns empty array if file doesn't exist. */
function readPins(workspaceId: string): PinnedItem[] {
const filePath = pinsFilePath(workspaceId);
function readPins(dataDir: string, workspaceId: string): PinnedItem[] {
const filePath = pinsFilePath(dataDir, workspaceId);
try {
if (fs.existsSync(filePath)) {
const raw = fs.readFileSync(filePath, 'utf-8');
@@ -47,8 +47,8 @@ function readPins(workspaceId: string): PinnedItem[] {
}
/** Write pins to disk. Creates directory if needed. */
function writePins(workspaceId: string, pins: PinnedItem[]): void {
const filePath = pinsFilePath(workspaceId);
function writePins(dataDir: string, workspaceId: string, pins: PinnedItem[]): void {
const filePath = pinsFilePath(dataDir, workspaceId);
const dir = path.dirname(filePath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
@@ -57,12 +57,14 @@ function writePins(workspaceId: string, pins: PinnedItem[]): void {
}
export const pinRoutes: FastifyPluginAsync = async (server) => {
const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle');
// GET /api/workspaces/:id/pins — list pins for workspace
server.get<{
Params: { id: string };
}>('/api/workspaces/:id/pins', async (request) => {
const { id } = request.params;
const pins = readPins(id);
const pins = readPins(dataDir, id);
return { pins };
});
@@ -86,7 +88,7 @@ export const pinRoutes: FastifyPluginAsync = async (server) => {
return reply.status(400).send({ error: 'messageRole must be "assistant" or "user"' });
}
const pins = readPins(id);
const pins = readPins(dataDir, id);
const pin: PinnedItem = {
id: crypto.randomUUID(),
workspaceId: id,
@@ -96,7 +98,7 @@ export const pinRoutes: FastifyPluginAsync = async (server) => {
label,
};
pins.push(pin);
writePins(id, pins);
writePins(dataDir, id, pins);
return reply.status(201).send({ pin });
});
@@ -113,7 +115,7 @@ export const pinRoutes: FastifyPluginAsync = async (server) => {
return reply.status(400).send({ error: 'status must be "draft" or "final"' });
}
const pins = readPins(id);
const pins = readPins(dataDir, id);
const pin = pins.find(p => p.id === pinId);
if (!pin) {
return reply.status(404).send({ error: 'Pin not found' });
@@ -122,7 +124,7 @@ export const pinRoutes: FastifyPluginAsync = async (server) => {
if (status !== undefined) pin.status = status;
if (label !== undefined) pin.label = label;
writePins(id, pins);
writePins(dataDir, id, pins);
return { pin };
});
@@ -131,13 +133,13 @@ export const pinRoutes: FastifyPluginAsync = async (server) => {
Params: { id: string; pinId: string };
}>('/api/workspaces/:id/pins/:pinId', async (request, reply) => {
const { id, pinId } = request.params;
const pins = readPins(id);
const pins = readPins(dataDir, id);
const idx = pins.findIndex(p => p.id === pinId);
if (idx === -1) {
return reply.status(404).send({ error: 'Pin not found' });
}
pins.splice(idx, 1);
writePins(id, pins);
writePins(dataDir, id, pins);
return { ok: true };
});
};

View File

@@ -383,7 +383,7 @@ export async function startService(options?: ServiceOptions): Promise<ServiceRes
server.agentState.currentModel = localModels[0];
} else {
providerHealth = 'degraded';
providerDetail = 'Built-in provider proxy (no API key, configure in Settings > API Keys)';
providerDetail = 'Built-in provider proxy (no API key, configure in Settings > Models)';
}
}