forked from OpenKnots/terminal-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Codex/atomic 10 terminal filter bar #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
himax12
wants to merge
5
commits into
clawgreen:main
Choose a base branch
from
himax12:codex/atomic-10-terminal-filter-bar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
78875b5
feat: add TerminalMarker component for feed phase separators (#7)
himax12 ac8b52c
feat: add TerminalLogLine primitive for structured log rows (#8)
himax12 905edf9
fix(terminal-log-line): meet all acceptance criteria
himax12 e0b661f
feat(terminal-log): add structured entries prop, keep lines backward-…
himax12 7b91ce2
feat: add TerminalFilterBar for level/source/text filtering (#10)
himax12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 'use client' | ||
|
|
||
| import { useMemo, useState } from 'react' | ||
| import { | ||
| Terminal, | ||
| TerminalCommand, | ||
| TerminalLog, | ||
| type LogEntry, | ||
| } from '@/components/terminal' | ||
| import { | ||
| TerminalFilterBar, | ||
| emptyFilterState, | ||
| filterEntries, | ||
| type FilterBarState, | ||
| } from '@/components/terminal-filter-bar' | ||
|
|
||
| const ALL_ENTRIES: LogEntry[] = [ | ||
| { id: '1', level: 'info', timestamp: '10:23:44', source: 'server', message: 'Application starting up...' }, | ||
| { id: '2', level: 'info', timestamp: '10:23:45', source: 'server', message: 'Listening on :3000' }, | ||
| { id: '3', level: 'debug', timestamp: '10:23:45', source: 'cache', message: 'HIT packages/[email protected]' }, | ||
| { id: '4', level: 'warn', timestamp: '10:23:46', source: 'cache', message: 'MISS @openknots/terminal-ui — fetching from registry' }, | ||
| { id: '5', level: 'info', timestamp: '10:23:47', source: 'build', message: 'Compiling 42 modules...' }, | ||
| { id: '6', level: 'debug', timestamp: '10:23:47', source: 'build', message: 'Resolved tsconfig paths in 4ms' }, | ||
| { id: '7', level: 'success', timestamp: '10:23:48', source: 'build', message: 'Compiled in 1.2s — 0 errors' }, | ||
| { id: '8', level: 'info', timestamp: '10:23:49', source: 'test', message: 'Running 24 unit tests...' }, | ||
| { id: '9', level: 'error', timestamp: '10:23:50', source: 'test', message: 'FAIL src/utils.test.ts — 1 snapshot mismatch' }, | ||
| { id: '10', level: 'info', timestamp: '10:23:50', source: 'test', message: 'Retrying with --updateSnapshot...' }, | ||
| { id: '11', level: 'success', timestamp: '10:23:51', source: 'test', message: '24 / 24 tests passed — coverage 94%' }, | ||
| { id: '12', level: 'info', timestamp: '10:23:52', source: 'deploy', message: 'Uploading artifacts to CDN...' }, | ||
| { id: '13', level: 'warn', timestamp: '10:23:52', source: 'deploy', message: 'Edge cache warm-up taking longer than 5s' }, | ||
| { id: '14', level: 'success', timestamp: '10:23:53', source: 'deploy', message: 'Published to production — https://example.app' }, | ||
| ] | ||
|
|
||
| const SOURCES = [...new Set(ALL_ENTRIES.map((e) => e.source!))] | ||
|
|
||
| export function FilterBarDemo() { | ||
| const [filter, setFilter] = useState<FilterBarState>(emptyFilterState) | ||
|
|
||
| const visible = useMemo(() => filterEntries(ALL_ENTRIES, filter), [filter]) | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-2"> | ||
| <TerminalFilterBar | ||
| state={filter} | ||
| onChange={setFilter} | ||
| sources={SOURCES} | ||
| /> | ||
| <Terminal title="pipeline.log"> | ||
| <TerminalCommand>pnpm run ci</TerminalCommand> | ||
| <TerminalLog entries={visible} maxLines={20} /> | ||
| </Terminal> | ||
| <p className="font-mono text-xs text-(--term-fg-dim)"> | ||
| {visible.length} / {ALL_ENTRIES.length} entries shown | ||
| </p> | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import { useEffect, useState } from 'react' | ||
| import { Terminal, TerminalCommand, TerminalLog } from '@/components/terminal' | ||
| import { Terminal, TerminalCommand, TerminalLog, type LogEntry } from '@/components/terminal' | ||
|
|
||
| // ── String-mode demo (unchanged) ───────────────────────────────────────────── | ||
|
|
||
| const STREAM_LINES = [ | ||
| '[info] Connecting to build worker...', | ||
|
|
@@ -38,3 +40,60 @@ export function LogDemo() { | |
| </Terminal> | ||
| ) | ||
| } | ||
|
|
||
| // ── Structured-mode demo ───────────────────────────────────────────────────── | ||
|
|
||
| const STREAM_ENTRIES: LogEntry[] = [ | ||
| { level: 'info', timestamp: '10:23:45', source: 'server', message: 'Worker connected' }, | ||
| { level: 'debug', timestamp: '10:23:46', source: 'cache', message: 'HIT packages/[email protected]' }, | ||
| { level: 'warn', timestamp: '10:23:47', source: 'cache', message: 'MISS @openknots/terminal-ui' }, | ||
| { level: 'info', timestamp: '10:23:48', source: 'build', message: 'Compiling 42 modules...' }, | ||
| { level: 'success', timestamp: '10:23:49', source: 'build', message: 'Compiled in 1.2s' }, | ||
| { level: 'info', timestamp: '10:23:50', source: 'test', message: 'Running 24 unit tests...' }, | ||
| { | ||
| level: 'error', | ||
| timestamp: '10:23:51', | ||
| source: 'test', | ||
| message: 'FAIL src/utils.test.ts — 1 snapshot mismatch', | ||
| }, | ||
| { | ||
| level: 'info', | ||
| timestamp: '10:23:52', | ||
| source: 'test', | ||
| message: 'Retrying with --updateSnapshot...', | ||
| }, | ||
| { level: 'success', timestamp: '10:23:53', source: 'test', message: '24 / 24 tests passed' }, | ||
| { level: 'success', timestamp: '10:23:54', source: 'deploy', message: 'Published to production' }, | ||
| ] | ||
|
|
||
| export function StructuredLogDemo() { | ||
| const [entries, setEntries] = useState<LogEntry[]>([ | ||
| { | ||
| id: 'boot-0', | ||
| level: 'info', | ||
| timestamp: '10:23:44', | ||
| source: 'server', | ||
| message: 'Starting pipeline...', | ||
| }, | ||
| ]) | ||
|
|
||
| useEffect(() => { | ||
| const timer = window.setInterval(() => { | ||
| setEntries((current) => { | ||
| const next = STREAM_ENTRIES[current.length % STREAM_ENTRIES.length] | ||
| return [...current, { ...next, id: String(current.length) }] | ||
| }) | ||
| }, 900) | ||
|
|
||
| return () => { | ||
| window.clearInterval(timer) | ||
| } | ||
| }, []) | ||
|
|
||
| return ( | ||
| <Terminal title="pipeline.log"> | ||
| <TerminalCommand>pnpm run ci</TerminalCommand> | ||
| <TerminalLog entries={entries} maxLines={8} autoScroll /> | ||
| </Terminal> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,8 +1,20 @@ | ||||
| import { TerminalApp } from '@/components/terminal-app' | ||||
| import { Terminal, TerminalCommand, TerminalDiff, TerminalOutput, TerminalSpinner, TerminalBadge, ThemeSwitcher } from '@/components/terminal' | ||||
| import { | ||||
| Terminal, | ||||
| TerminalCommand, | ||||
| TerminalDiff, | ||||
| TerminalOutput, | ||||
| TerminalSpinner, | ||||
| TerminalBadge, | ||||
| TerminalMarker, | ||||
| TerminalLogLine, | ||||
| ThemeSwitcher, | ||||
| } from '@/components/terminal' | ||||
| import { TerminalProgress } from '@/components/terminal-progress' | ||||
| import { LogDemo } from './log-demo' | ||||
| import { LogDemo, StructuredLogDemo } from './log-demo' | ||||
| import { FilterBarDemo } from './filter-demo' | ||||
| import { PromptDemo } from './prompt-demo' | ||||
| import { SearchDemo } from './search-demo' | ||||
|
||||
| import { SearchDemo } from './search-demo' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn’t appear to be formatted with the repo’s Prettier config (e.g., extra alignment spaces in object literals and long lines that would normally wrap). Running
pnpm format(or formatting this file) will prevent noisy diffs and keep formatting consistent.