Repository navigation
fix(slate): isolate compatibility failures and verify Pi upgrades + undici bumps #125
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
Merged
+1,414
−1,058
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
389d5c4
fix(slate): isolate compatibility failures and test upstream hosts
GaganSD 277cd98
fix(deps): update shared Undici override to patched 8.12.4
GaganSD bb8e2b4
test(insights): synchronize worker lifecycle assertions
GaganSD fe43637
refactor(slate): require explicit chat-view consumption predicates
GaganSD 84d81ca
refactor(slate): give chat rendering a single surface owner
GaganSD a399b04
fix(slate): plan tool groups before painting
GaganSD 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
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,34 @@ | ||
| name: Slate upstream compatibility | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '19 6 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: slate-upstream-compatibility | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| compatibility: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version: '24' | ||
| cache: npm | ||
| cache-dependency-path: pi-slate/package-lock.json | ||
| - run: npm ci --prefix pi-slate --ignore-scripts --no-audit --no-fund | ||
| - name: Real interactive baseline | ||
| run: npm run test:compat --prefix pi-slate | ||
| - name: Build and smoke-test artifact | ||
| run: npm run build --prefix pi-slate | ||
| - name: Real interactive latest Pi with packed Slate | ||
| run: npm run test:compat:latest --prefix pi-slate |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,108 @@ | ||
| import { Container, ScrollView, isViewportTUI, type Component, type TUI } from "@earendil-works/pi-tui"; | ||
| import type { ToolGroups } from "./tool-groups.ts"; | ||
|
|
||
| export function childComponents(component: Component): Component[] { | ||
| const stack = component as { entries?: Array<{ component?: Component }> }; | ||
| if (Array.isArray(stack.entries) && stack.entries.some((entry) => entry?.component)) { | ||
| return stack.entries.flatMap((entry) => (entry.component ? [entry.component] : [])); | ||
| } | ||
| const container = component as Container; | ||
| return Array.isArray(container.children) ? container.children : []; | ||
| } | ||
|
|
||
| export function findPrimaryScrollView(root: Component): ScrollView | undefined { | ||
| const seen = new Set<Component>(); | ||
| const queue = [root]; | ||
| while (queue.length > 0) { | ||
| const node = queue.shift(); | ||
| if (!node || seen.has(node)) continue; | ||
| seen.add(node); | ||
| if (node instanceof ScrollView && node.primary) return node; | ||
| queue.push(...childComponents(node)); | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| export function findChatContainer(root: Component | undefined): Container | undefined { | ||
| if (!root) return undefined; | ||
| const scroll = findPrimaryScrollView(root); | ||
| if (!scroll) return undefined; | ||
| const content = childComponents(scroll)[0]; | ||
| if (!content || typeof (content as Container).addChild !== "function") return undefined; | ||
| const nested = childComponents(content).filter((child) => ( | ||
| child instanceof Container && !(child instanceof ScrollView) | ||
| )); | ||
| const chat = nested.at(-1) ?? content; | ||
| return typeof (chat as Container).addChild === "function" ? chat as Container : undefined; | ||
| } | ||
|
|
||
| export function layoutRootOf(tui: TUI | undefined): Component | undefined { | ||
| if (!tui || !isViewportTUI(tui)) return undefined; | ||
| return (tui as TUI & { layoutRoot?: Component }).layoutRoot; | ||
| } | ||
|
|
||
| export type ChatSurfaceOptions = { | ||
| limit?: number; | ||
| groups?: ToolGroups; | ||
| active?: () => boolean; | ||
| onGroupingFault?: () => void; | ||
| }; | ||
|
|
||
| /** One owner for the display pipeline: project first, then paint grouped or native rows. */ | ||
| export class ChatSurface { | ||
| readonly container: Container; | ||
| private options: ChatSurfaceOptions; | ||
| private readonly originalRender: Container["render"]; | ||
| private readonly originalMouse: Container["handleMouse"]; | ||
| private readonly installedRender: Container["render"]; | ||
| private readonly installedMouse: Container["handleMouse"]; | ||
| private readonly display = new Container(); | ||
| private paintedGroups: ToolGroups | undefined; | ||
| private disposed = false; | ||
|
|
||
| constructor(container: Container, options: ChatSurfaceOptions) { | ||
| this.container = container; this.options = { ...options }; | ||
| if (container.render !== Container.prototype.render || container.handleMouse !== Container.prototype.handleMouse) { | ||
| throw new Error("Unrecognized chat owner; native transcript retained"); | ||
| } | ||
| this.originalRender = container.render; | ||
| this.originalMouse = container.handleMouse; | ||
| this.installedRender = width => { | ||
| if (this.disposed) return this.originalRender.call(container, width); | ||
| const limit = this.options.limit ?? Number.POSITIVE_INFINITY; | ||
| const start = !this.options.active?.() && Number.isFinite(limit) ? -Math.max(1, Math.floor(limit)) : 0; | ||
| this.display.children = container.children.slice(start); | ||
| this.paintedGroups = undefined; | ||
| if (this.options.groups) { | ||
| try { | ||
| const rows = this.options.groups.render(this.display.children, width); | ||
| this.paintedGroups = this.options.groups; | ||
| return rows; | ||
| } catch { | ||
| this.options.groups = undefined; | ||
| this.options.onGroupingFault?.(); | ||
| } | ||
| } | ||
| return this.display.render(width); | ||
| }; | ||
| this.installedMouse = event => { | ||
| if (this.disposed) return this.originalMouse.call(container, event); | ||
| return this.paintedGroups ? this.paintedGroups.handleMouse(event) : this.display.handleMouse(event); | ||
| }; | ||
| try { | ||
| container.render = this.installedRender; | ||
| container.handleMouse = this.installedMouse; | ||
| } catch (error) { this.dispose(); throw error; } | ||
| } | ||
|
|
||
| update(options: ChatSurfaceOptions): void { if (!this.disposed) this.options = { ...options }; } | ||
| dispose(): void { | ||
| if (this.disposed) return; | ||
| this.disposed = true; | ||
| if (this.container.render === this.installedRender) this.container.render = this.originalRender; | ||
| if (this.container.handleMouse === this.installedMouse) this.container.handleMouse = this.originalMouse; | ||
| this.display.children = []; | ||
| this.paintedGroups = undefined; | ||
| this.options = {}; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.