chore: update plan automation and chat status UI

This commit is contained in:
2026-04-23 20:27:40 +09:00
parent 6e863feafd
commit 346d4c2208
26 changed files with 317 additions and 74 deletions

View File

@@ -0,0 +1,94 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
const DEFAULT_CAPTURE_STORAGE_KEY = 'work-app.token-access.registered-token';
const DEFAULT_CAPTURE_BASE_URL = 'https://test.sm-home.cloud/';
function stripWrappingQuotes(value) {
if (!value) {
return value;
}
if (
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
) {
return value.slice(1, -1);
}
return value;
}
function applyEnvFile(filePath) {
if (!fs.existsSync(filePath)) {
return;
}
const content = fs.readFileSync(filePath, 'utf8');
for (const rawLine of content.split(/\r?\n/u)) {
const line = rawLine.trim();
if (!line || line.startsWith('#')) {
continue;
}
const separatorIndex = line.indexOf('=');
if (separatorIndex <= 0) {
continue;
}
const key = line.slice(0, separatorIndex).trim();
const value = stripWrappingQuotes(line.slice(separatorIndex + 1).trim());
if (!key || process.env[key] !== undefined) {
continue;
}
process.env[key] = value;
}
}
function loadCaptureEnv(cwd = process.cwd()) {
applyEnvFile(path.join(cwd, '.env'));
applyEnvFile(path.join(cwd, 'etc/servers/work-server/.env'));
}
export function getCaptureRuntimeConfig(cwd = process.cwd()) {
loadCaptureEnv(cwd);
return {
baseUrl:
process.env.CAPTURE_BASE_URL?.trim() ||
process.env.SERVER_COMMAND_TEST_URL?.trim() ||
DEFAULT_CAPTURE_BASE_URL,
tokenAccessStorageKey:
process.env.CAPTURE_REGISTERED_ACCESS_STORAGE_KEY?.trim() || DEFAULT_CAPTURE_STORAGE_KEY,
registeredAccessToken:
process.env.CAPTURE_REGISTERED_ACCESS_TOKEN?.trim() ||
process.env.VITE_ALLOWED_REGISTRATION_TOKEN?.trim() ||
process.env.SERVER_COMMAND_ACCESS_TOKEN?.trim() ||
'',
};
}
export async function createCaptureContext(browser, options = {}) {
const { tokenAccessStorageKey, registeredAccessToken } = getCaptureRuntimeConfig();
const context = await browser.newContext(options);
if (registeredAccessToken) {
await context.addInitScript(
({ accessToken, storageKey }) => {
window.localStorage.setItem(storageKey, accessToken);
},
{
accessToken: registeredAccessToken,
storageKey: tokenAccessStorageKey,
},
);
}
return context;
}

View File

@@ -1,11 +1,12 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const cwd = process.cwd();
const componentId = process.argv[2];
const captureDate = process.argv[3] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
if (!componentId) {
console.error('Usage: node scripts/capture-component-screenshot.mjs <component-id> [YYYY-MM-DD]');
@@ -21,13 +22,14 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
const targetSelector = `#component-sample-${componentId}`;
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({
const context = await createCaptureContext(browser, {
viewport: {
width: 1600,
height: 1200,
},
deviceScaleFactor: 2,
});
const page = await context.newPage();
try {
await ensureDirectory(screenshotDir);
@@ -59,5 +61,6 @@ try {
console.log(`Saved: ${screenshotPath}`);
console.log(`Linked in: ${worklogPath}`);
} finally {
await context.close();
await browser.close();
}

View File

@@ -1,5 +1,6 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const FEATURE_CAPTURE_PRESETS = {
@@ -56,7 +57,7 @@ const FEATURE_CAPTURE_PRESETS = {
const cwd = process.cwd();
const presetKey = process.argv[2];
const captureDate = process.argv[3] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
if (!presetKey || !(presetKey in FEATURE_CAPTURE_PRESETS)) {
console.error(`Usage: node scripts/capture-feature-screenshot.mjs <${Object.keys(FEATURE_CAPTURE_PRESETS).join('|')}> [YYYY-MM-DD]`);
@@ -71,10 +72,11 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({
const context = await createCaptureContext(browser, {
viewport: { width: 1600, height: 1200 },
deviceScaleFactor: 2,
});
const page = await context.newPage();
try {
await ensureDirectory(screenshotDir);
@@ -113,5 +115,6 @@ try {
console.log(`Saved: ${screenshotPath}`);
console.log(`Linked in: ${worklogPath}`);
} finally {
await context.close();
await browser.close();
}

View File

@@ -1,10 +1,11 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const cwd = process.cwd();
const captureDate = process.argv[2] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
const screenshotFileName = 'main-content-fullscreen-toggle.png';
const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolveCapturePaths({
cwd,
@@ -13,10 +14,11 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({
const context = await createCaptureContext(browser, {
viewport: { width: 1600, height: 1200 },
deviceScaleFactor: 2,
});
const page = await context.newPage();
try {
await ensureDirectory(screenshotDir);
@@ -41,5 +43,6 @@ try {
console.log(`Saved: ${screenshotPath}`);
console.log(`Linked in: ${worklogPath}`);
} finally {
await context.close();
await browser.close();
}

View File

@@ -1,11 +1,12 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const cwd = process.cwd();
const menuGroup = process.argv[2] ?? 'docs';
const captureDate = process.argv[3] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
const supportedMenuGroups = new Set(['docs', 'plans']);
@@ -22,10 +23,11 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({
const context = await createCaptureContext(browser, {
viewport: { width: 1600, height: 1200 },
deviceScaleFactor: 2,
});
const page = await context.newPage();
try {
await ensureDirectory(screenshotDir);
@@ -57,5 +59,6 @@ try {
console.log(`Saved: ${screenshotPath}`);
console.log(`Linked in: ${worklogPath}`);
} finally {
await context.close();
await browser.close();
}

View File

@@ -1,10 +1,11 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const cwd = process.cwd();
const captureDate = process.argv[2] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
const screenshotFileName = 'plan-board-mobile-memo-detail.png';
const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolveCapturePaths({
cwd,
@@ -13,7 +14,7 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
const context = await createCaptureContext(browser, {
viewport: { width: 430, height: 932 },
isMobile: true,
hasTouch: true,

View File

@@ -1,10 +1,11 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const cwd = process.cwd();
const captureDate = process.argv[2] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:5174';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
const screenshotFileName = 'search-command.png';
const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolveCapturePaths({
cwd,
@@ -13,7 +14,7 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
const context = await createCaptureContext(browser, {
viewport: { width: 430, height: 932 },
isMobile: true,
hasTouch: true,

View File

@@ -1,10 +1,8 @@
import process from 'node:process';
import { chromium } from 'playwright';
import { createCaptureContext, getCaptureRuntimeConfig } from './capture-auth-utils.mjs';
import { ensureDirectory, getKstDate, resolveCapturePaths, updateWorklogCaptureSection } from './worklog-capture-utils.mjs';
const ACCESS_TOKEN = 'usr_7f3a9c2d8e1b4a6f';
const TOKEN_ACCESS_STORAGE_KEY = 'work-app.token-access.registered-token';
const SETTINGS_CAPTURE_PRESETS = {
automation: {
screenshotFileName: 'settings-app.png',
@@ -19,7 +17,7 @@ const SETTINGS_CAPTURE_PRESETS = {
const cwd = process.cwd();
const presetKey = process.argv[2];
const captureDate = process.argv[3] ?? getKstDate();
const baseUrl = process.env.CAPTURE_BASE_URL ?? 'http://127.0.0.1:4173';
const { baseUrl } = getCaptureRuntimeConfig(cwd);
if (!presetKey || !(presetKey in SETTINGS_CAPTURE_PRESETS)) {
console.error(`Usage: node scripts/capture-settings-screenshot.mjs <${Object.keys(SETTINGS_CAPTURE_PRESETS).join('|')}> [YYYY-MM-DD]`);
@@ -34,21 +32,11 @@ const { screenshotDir, screenshotPath, worklogPath, markdownImagePath } = resolv
});
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
const context = await createCaptureContext(browser, {
viewport: { width: 1600, height: 1200 },
deviceScaleFactor: 2,
});
await context.addInitScript(
({ tokenAccessStorageKey, accessToken }) => {
window.localStorage.setItem(tokenAccessStorageKey, accessToken);
},
{
tokenAccessStorageKey: TOKEN_ACCESS_STORAGE_KEY,
accessToken: ACCESS_TOKEN,
},
);
const page = await context.newPage();
try {