Skip to content

Commit 8daecfa

Browse files
feat: dynamic tabs. (#64)
1 parent 7832231 commit 8daecfa

27 files changed

Lines changed: 4784 additions & 1886 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ browser acts as the runtime host for render, lint, and typecheck flows.
2525
`@knighted/develop` lets you:
2626

2727
- write component code in the browser
28+
- manage dynamic workspace tabs with add, rename, remove, and entry-role protection
2829
- switch render mode between DOM and React
2930
- switch style mode between native CSS, CSS Modules, Less, and Sass
3031
- run in-browser lint and type diagnostics

docs/next-steps.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,7 @@ Focused follow-up work for `@knighted/develop`.
1919
- Suggested implementation prompt:
2020
- "Add a deterministic E2E execution mode for `@knighted/develop` that serves pinned runtime artifacts locally (instead of live CDN fetches) and wire it into CI as a required check on every PR. Keep a separate lightweight CDN-smoke E2E check for real-network coverage. Validate with `npm run lint`, deterministic Playwright PR checks, and one CDN-smoke Playwright run."
2121

22-
4. **Phase 2 UX/UI continuation: fixed editor tabs first pass (Component, Styles, App)**
23-
- Continue the tabs/editor UX work with a constrained first implementation that supports exactly three editor tabs: Component, Styles, and App.
24-
- Do not introduce arbitrary/custom tab names in this pass; treat custom naming as future scope after baseline tab behavior is stable.
25-
- Preserve existing runtime behavior and editor content semantics while adding tab switching, active tab indication, and predictable persistence/reset behavior consistent with current app patterns.
26-
- Ensure assistant/editor integration remains compatible with this model (edits should target one of the fixed tabs) without expanding to dynamic tab metadata yet.
27-
- Suggested implementation prompt:
28-
- "Implement Phase 2 UX/UI tab support in @knighted/develop with a fixed first-pass tab model: Component, Styles, and App only (no arbitrary tab names yet). Add a clear tab UI for switching editor panes, preserve existing editor behavior/content wiring, and keep render/lint/typecheck/diagnostics flows working with the selected tab context where relevant. Keep AI chat feature-flag behavior unchanged while keeping PR/BYOT controls available by default, maintain CDN-first runtime constraints, and do not add dependencies. Add targeted Playwright coverage for tab switching, default/active tab behavior, and interactions with existing render/style-mode flows. Validate with npm run lint and targeted Playwright tests."
29-
30-
5. **Document implicit App strict-flow behavior (auto render)**
31-
- Add a short behavior matrix in docs that explains when implicit App wrapping is allowed versus when users must define `App` explicitly.
32-
- Include concrete Component editor examples for each case so reviewer/user expectations are clear.
33-
- Suggested example cases to document:
34-
- Allowed implicit wrap (standalone top-level JSX, no imports/declarations), for example:
35-
- `(<button type="button">Standalone</button>) as any`
36-
- Requires explicit `App` (top-level JSX with declarations/imports), for example:
37-
- `const label = 'Hello'`
38-
- `const Button = () => <button>{label}</button>`
39-
- `(<Button />) as any`
40-
- Recommended explicit pattern, for example:
41-
- `const Button = () => <button>Hello</button>`
42-
- `const App = () => <Button />`
43-
- Suggested implementation prompt:
44-
- "Document the current implicit App behavior in @knighted/develop for auto-render mode using a compact behavior matrix and concrete component-editor snippets. Clearly distinguish supported implicit wrapping from cases that intentionally require an explicit App (such as top-level JSX mixed with imports/declarations). Keep docs concise, aligned with current runtime behavior, and include at least one positive and one explicit-error example."
45-
46-
6. **Evaluate GitHub file upsert request strategy (metadata-first vs optimistic PUT)**
22+
4. **Evaluate GitHub file upsert request strategy (metadata-first vs optimistic PUT)**
4723
- Revisit the current metadata-first `upsertRepositoryFile` approach and compare it against an optimistic PUT + targeted retry-on-missing-sha flow.
4824
- Measure tradeoffs for latency, GitHub API request count/rate-limit impact, and browser-console signal quality during common PR flows.
4925
- If beneficial, introduce a configurable/hybrid strategy (for example, optimistic default with metadata fallback) without regressing current reliability.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Render Pipeline + Multi-Tab Spec Plan
2+
3+
This document outlines test coverage to add after the render pipeline rewrite is fully integrated with the multi-tab UX.
4+
5+
## Why this plan exists
6+
7+
Current test coverage intentionally removed a subset of specs that were tightly coupled to pre-rewrite assumptions:
8+
9+
1. Legacy assumptions around default-export hydration behavior in preview module assembly.
10+
2. Styles diagnostics behavior that depended on old compile/lint sequencing.
11+
3. PR drawer path validation timing assumptions tied to previous field sync flow.
12+
13+
These should return as updated tests once the new pipeline contract is finalized.
14+
15+
## Proposed Test Areas
16+
17+
## 1. Entry Resolution and Execution Semantics
18+
19+
Goal: Validate how preview entry is resolved from workspace tabs under the `role: entry` model.
20+
21+
Add specs for:
22+
23+
1. Entry selection prefers explicit `role: entry`, with documented fallback behavior only when no explicit entry is present.
24+
2. Entry rename between `App.tsx` and `App.js` keeps execution stable.
25+
3. Entry path updates preserve directory while enforcing filename convention.
26+
4. Reload restores same entry tab and executes same source.
27+
28+
## 2. Default Export Handling in New Hydration Pipeline
29+
30+
Goal: Reintroduce export-default tests against the final module assembly support matrix.
31+
32+
Add specs for:
33+
34+
1. `export default () => ...` in entry tab with manual render.
35+
2. `export default class ...` in React mode.
36+
3. `function App() { ... } export default App` compatibility.
37+
4. `const Button = ...; export default Button` behavior when App wrapper is implicit or explicit.
38+
5. Negative cases: unsupported default-export combinations produce deterministic diagnostics.
39+
40+
## 3. Cross-Tab Import Graph Hydration
41+
42+
Goal: Ensure workspace graph resolution works across multiple component and style tabs.
43+
44+
Add specs for:
45+
46+
1. Entry imports sibling component tab by relative specifier.
47+
2. Nested dependency chain (A imports B imports C) hydrates in stable order.
48+
3. Missing module path reports actionable preview error including unresolved specifier.
49+
4. Circular import emits stable error (or supported behavior) without hanging.
50+
5. Windows-style and POSIX-style separators normalize consistently in lookup keys.
51+
52+
## 4. Styles Pipeline and Diagnostics Contract
53+
54+
Goal: Lock down expected diagnostics and status transitions for style dialects.
55+
56+
Add specs for:
57+
58+
1. Sass compilation error sets diagnostics state to error with styles-scope detail.
59+
2. Less error path behavior parity with Sass.
60+
3. Switching style mode clears stale diagnostics according to final pipeline contract.
61+
4. Styles lint diagnostics and compile diagnostics coexist or prioritize per contract.
62+
5. Clearing style diagnostics does not clear unrelated component diagnostics.
63+
64+
## 5. Status and Diagnostics State Machine
65+
66+
Goal: Ensure app status text/class and diagnostics toggle class remain consistent.
67+
68+
Add specs for:
69+
70+
1. Pending to error to neutral transitions for typecheck + lint + render.
71+
2. Multiple error sources aggregate counts correctly.
72+
3. Clearing one scope updates only corresponding status/diagnostics indicators.
73+
4. Auto-render off path keeps status stable until explicit render.
74+
75+
## 6. Multi-Tab Tool Visibility and Actionability
76+
77+
Goal: Guarantee controls are actionable only for active editor tab and panel.
78+
79+
Add specs for:
80+
81+
1. Component controls hidden/inert when styles tab is active.
82+
2. Styles controls hidden/inert when component tab is active.
83+
3. Keyboard interactions in inactive panel do not mutate source.
84+
4. Tab switches maintain tool visibility state and collapse state correctly.
85+
86+
## 7. Persistence and Isolation Guarantees
87+
88+
Goal: Verify deterministic startup and no stale state bleed between sessions.
89+
90+
Add specs for:
91+
92+
1. IndexedDB workspace restore across reload preserves tabs, active tab, entry role, and paths.
93+
2. PR drawer saved config does not unexpectedly overwrite active workspace tab paths.
94+
3. New session starts clean when storage is reset in tests.
95+
4. Repository switch behavior isolates per-repo local context and config.
96+
97+
## 8. PR Drawer Path Validation and Sync
98+
99+
Goal: Revisit path validation behavior after final field sync implementation.
100+
101+
Add specs for:
102+
103+
1. Reject traversal (`../`) for component and styles paths.
104+
2. Reject trailing slash paths for component and styles fields.
105+
3. Allow dotted segments that are not traversal.
106+
4. Entry-specific filename rule enforcement (`App.tsx` or `App.js`) reflected in drawer path values.
107+
108+
## 9. Test Infrastructure Improvements
109+
110+
Goal: Keep suites stable as UX evolves.
111+
112+
Actions:
113+
114+
1. Add helper APIs for tab activation before control interactions.
115+
2. Add one reset helper per suite to clear localStorage, sessionStorage, and IndexedDB.
116+
3. Prefer role/name selectors that match active-tab semantics.
117+
4. Avoid assertions that require hidden panel controls to be clickable.
118+
119+
## Suggested Rollout Order
120+
121+
1. Entry resolution + default-export support matrix.
122+
2. Cross-tab import graph hydration.
123+
3. Styles diagnostics contract.
124+
4. Status state machine.
125+
5. PR drawer path validation synchronization.
126+
6. Persistence/isolation hardening.
127+
128+
## Definition of Done for this plan
129+
130+
Before reintroducing removed specs, the render pipeline implementation should provide a written behavior contract for:
131+
132+
1. Entry tab selection.
133+
2. Default export support matrix.
134+
3. Style compile + lint diagnostics precedence.
135+
4. Status/diagnostics state transitions.
136+
5. Path normalization and validation across workspace tabs and PR drawer fields.

docs/webkit-open-pr-drawer-triage.md

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)