{"record":{"id":"c7cbea8c7bb49c72","repo":"jlcodes99/cockpit-tools","slug":"workbuddyautocheckin","errorCode":null,"errorMessage":"[WorkbuddyAutoCheckin] 清理废弃的自动签到日志缓存失败:","messagePattern":"\\[WorkbuddyAutoCheckin\\] 清理废弃的自动签到日志缓存失败:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/services/workbuddyAutoCheckinService.ts","lineNumber":42,"sourceCode":"const LEGACY_LOGS_KEY = 'agtools.workbuddy.auto_checkin_logs';\nexport const WORKBUDDY_AUTO_CHECKIN_CONFIG_CHANGED_EVENT = 'workbuddy-auto-checkin-config-changed';\nconst AUTO_CHECKIN_RETRY_DELAY_MS = 5 * 60 * 1000;\nconst AUTO_CHECKIN_IDLE_RECHECK_DELAY_MS = 60 * 60 * 1000;\n\nexport type WorkbuddyAutoCheckinCycleResult = 'disabled' | 'waiting' | 'completed' | 'retry';\n\nexport function clearLegacyWorkbuddyAutoCheckinLogs(): void {\n  if (typeof window === 'undefined') {\n    return;\n  }\n\n  try {\n    if (localStorage.getItem(LEGACY_LOGS_KEY) !== null) {\n      localStorage.removeItem(LEGACY_LOGS_KEY);\n      console.info('[WorkbuddyAutoCheckin] 已清理废弃的 WebView 自动签到日志缓存');\n    }\n  } catch (err) {\n    console.warn('[WorkbuddyAutoCheckin] 清理废弃的自动签到日志缓存失败:', err);\n  }\n}\n\nlet cachedConfig: WorkbuddyAutoCheckinConfig | null = null;\n\nfunction isValidTime(time: unknown): time is string {\n  return typeof time === 'string' && /^([01]\\d|2[0-3]):[0-5]\\d$/.test(time);\n}\n\nfunction cacheConfigLocally(config: WorkbuddyAutoCheckinConfig, emitChange = false): void {\n  cachedConfig = config;\n  if (typeof window === 'undefined') {\n    return;\n  }\n  try {\n    localStorage.setItem(CONFIG_KEY, JSON.stringify(config));\n    if (emitChange) {\n      window.dispatchEvent(new Event(WORKBUDDY_AUTO_CHECKIN_CONFIG_CHANGED_EVENT));","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/services/workbuddyAutoCheckinService.ts#L24-L60","documentation":"clearLegacyWorkbuddyAutoCheckinLogs removes an obsolete WebView-era logs key from localStorage. Failures are caught and warned because leftover legacy data is harmless; the cleanup is purely hygienic.","triggerScenarios":"localStorage.removeItem or getItem throws — storage disabled, quota error surfaced on remove, or access denied in private/policy-restricted browsing contexts.","commonSituations":"Upgrading from a WebView build where localStorage is blocked by the embedder; hardened browser settings with storage APIs disabled.","solutions":["Verify localStorage is accessible before attempting cleanup","Skip the cleanup when storage is unavailable — legacy data is inert","Manually clear site data in the browser to remove the legacy key"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function storageAvailable(): boolean {\n  try { const k = '__t__'; localStorage.setItem(k, k); localStorage.removeItem(k); return true; }\n  catch { return false; }\n}\nif (storageAvailable()) clearLegacyWorkbuddyAutoCheckinLogs();","typeGuard":null,"tryCatchPattern":"try {\n  if (localStorage.getItem(LEGACY_LOGS_KEY) !== null) localStorage.removeItem(LEGACY_LOGS_KEY);\n} catch (err) {\n  console.warn('[WorkbuddyAutoCheckin] 清理废弃的自动签到日志缓存失败:', err);\n}","preventionTips":["No-op when storage is unavailable — legacy data is harmless","Run legacy cleanup once per version behind a flag","Clear site data manually if the key must go"],"tags":["localstorage","migration","legacy-cleanup"],"backgroundTag":"localstorage-access-denied","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}