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
8 changes: 1 addition & 7 deletions src/tui/screens/ManifestPathPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export function ManifestPathPicker({ mode }: { mode: ManifestPathPickerMode }) {
});
}

const screenTitle = mode === 'add' ? 'add' : 'rm';
const screenLabel = mode === 'add' ? copy.add : copy.rm;
const homeTitle = mode === 'add' ? copy.addDesc : copy.rmDesc;
const reviewTitle = mode === 'add' ? 'confirm add to manifest' : 'confirm remove from manifest';
const reviewYes = mode === 'add' ? 'Yes — add these paths' : 'Yes — remove these manifest paths';

Expand Down Expand Up @@ -106,11 +104,7 @@ export function ManifestPathPicker({ mode }: { mode: ManifestPathPickerMode }) {

if (phase === 'home') {
return (
<ScreenFrame
title={screenLabel}
subtitle={homeTitle}
footer={`${ESCAPE_LIKE_HINT} → main menu`}
>
<ScreenFrame title={screenLabel} footer={`${ESCAPE_LIKE_HINT} → main menu`}>
<Text dimColor>Project root: {projectRoot}</Text>
<SelectInput
items={[
Expand Down
1 change: 0 additions & 1 deletion src/tui/screens/ScreenDoctor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export function ScreenDoctor() {
return (
<ScreenFrame
title={copy.doctor}
subtitle={copy.doctorDesc}
stats={
rep
? [
Expand Down
6 changes: 1 addition & 5 deletions src/tui/screens/ScreenInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export function ScreenInit() {
}, [db, cwd, reporter, refreshProject]);

return (
<ScreenFrame
title={copy.init}
subtitle={copy.initDesc}
footer={!end ? `${ESCAPE_LIKE_HINT} → main menu` : undefined}
>
<ScreenFrame title={copy.init} footer={!end ? `${ESCAPE_LIKE_HINT} → main menu` : undefined}>
<ReporterShell state={rs} setState={setRs} />
{end && (
<Box marginTop={1} flexDirection="column">
Expand Down
5 changes: 1 addition & 4 deletions src/tui/screens/ScreenLs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ export function ScreenLs() {
<ManifestEntryTreeBrowse
entries={entries}
title="ls (manifest)"
subtitles={[
`Project: ${currentProject.alias}`,
'[+] include · [!] exclude · [±] both · [·] implicit folder (no own row)',
]}
subtitles={[`Project: ${currentProject.alias}`, '[+] include · [!] exclude · [±] both']}
onBack={() => setScreen('main')}
backTarget="main menu"
/>
Expand Down
28 changes: 20 additions & 8 deletions src/tui/screens/ScreenProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import { ESCAPE_LIKE_HINT, wantsEscapeLike } from '../escapeLike.js';

type Phase = 'list' | 'detail';

/** 短时间戳:YYYY-MM-DD HH:mm(UTC),去掉秒与毫秒,避免详情页被长 ISO 串占满。 */
function shortTimestamp(ms: number): string {
return new Date(ms).toISOString().slice(0, 16).replace('T', ' ');
}

/** 过长字符串中段省略,保留首尾以便辨认(如长 remote URL)。 */
function truncateMiddle(s: string, max: number): string {
if (s.length <= max) return s;
const keep = max - 1;
const head = Math.ceil(keep / 2);
const tail = Math.floor(keep / 2);
return `${s.slice(0, head)}…${s.slice(s.length - tail)}`;
}

export function ScreenProjects() {
const { db, setScreen, copy } = useTui();
const [phase, setPhase] = useState<Phase>('list');
Expand Down Expand Up @@ -41,17 +55,16 @@ export function ScreenProjects() {
}, [phase, detail, db]);

if (phase === 'detail' && detail) {
const lastSaved =
detail.lastSavedAt != null ? new Date(detail.lastSavedAt).toISOString() : 'never';
const lastSaved = detail.lastSavedAt != null ? shortTimestamp(detail.lastSavedAt) : 'never';
const subtitles = [`${copy.managed}: ${detail.fileCount} · ${lastSaved}`];
if (detail.remote_url) {
subtitles.push(`${copy.remote}: ${truncateMiddle(detail.remote_url, 48)}`);
}
return (
<ManifestEntryTreeBrowse
entries={entries}
title={`${copy.project}: ${detail.alias}`}
subtitles={[
`${copy.managed}: ${detail.fileCount}`,
`last save: ${lastSaved}`,
detail.remote_url ? `${copy.remote}: ${detail.remote_url}` : `${copy.remote}: (none)`,
]}
subtitles={subtitles}
onBack={() => {
setDetail(null);
setPhase('list');
Expand All @@ -64,7 +77,6 @@ export function ScreenProjects() {
return (
<ScreenFrame
title={copy.projects}
subtitle={copy.projectsDesc}
stats={[
{ label: copy.managed, value: rows.length, color: rows.length ? 'green' : undefined },
]}
Expand Down
1 change: 0 additions & 1 deletion src/tui/screens/ScreenRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function ScreenRules() {
return (
<ScreenFrame
title={copy.rules}
subtitle={copy.rulesDesc}
stats={[
{ label: copy.defaultRule, value: rules.filter((r) => r.isDefault).length },
{ label: copy.customRule, value: rules.filter((r) => !r.isDefault).length },
Expand Down
6 changes: 1 addition & 5 deletions src/tui/screens/ScreenSave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ export function ScreenSave() {
}, [db, cwd, reporter]);

return (
<ScreenFrame
title={copy.save}
subtitle={copy.saveDesc}
footer={!end ? `${ESCAPE_LIKE_HINT} → main menu` : undefined}
>
<ScreenFrame title={copy.save} footer={!end ? `${ESCAPE_LIKE_HINT} → main menu` : undefined}>
<ReporterShell state={rs} setState={setRs} />
{end && (
<Box marginTop={1} flexDirection="column">
Expand Down
12 changes: 9 additions & 3 deletions src/tui/screens/ScreenStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Text, useInput } from 'ink';
import { Text, useInput } from 'ink';
import { useEffect, useState } from 'react';
import { status } from '../../commands/status.js';
import { ScreenFrame } from '../components/ScreenFrame.js';
Expand Down Expand Up @@ -30,11 +30,11 @@ export function ScreenStatus() {
missing: c.created.length,
unchanged: c.unchanged.length,
});
// 仅列出有变化的条目;未变更文件只在顶部计数中体现,避免刷屏。
const out: string[] = [];
for (const p of c.created) out.push(`! ${p}`);
for (const p of c.changed) out.push(`~ ${p}`);
for (const p of c.untracked) out.push(`? ${p}`);
for (const p of c.unchanged) out.push(` ${p}`);
setLines(out);
} catch (e) {
setErr((e as Error).message);
Expand Down Expand Up @@ -69,7 +69,13 @@ export function ScreenStatus() {
}
footer={`${ESCAPE_LIKE_HINT} → main menu`}
>
{err ? <Text color="red">{err}</Text> : lines.map((l) => <Text key={l}>{l}</Text>)}
{err ? (
<Text color="red">{err}</Text>
) : lines.length === 0 ? (
<Text dimColor>{`✓ ${copy.unchanged}`}</Text>
) : (
lines.map((l) => <Text key={l}>{l}</Text>)
)}
</ScreenFrame>
);
}
1 change: 0 additions & 1 deletion src/tui/screens/ScreenTrash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function ScreenTrash() {
return (
<ScreenFrame
title={copy.trash}
subtitle={copy.trashDesc}
stats={[{ label: copy.files, value: rows.reduce((sum, row) => sum + row.files.length, 0) }]}
footer={`${ESCAPE_LIKE_HINT} → main menu`}
>
Expand Down
Loading