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
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,20 @@ def start(self, server):
from loopx.extensions.lark.conversation_identity import identity_ref
from loopx.chat_store import _atomic_write_json
event = self.reply_event()
parent = "原要求:保留已有结果和失败记录。Original requirement: retain results and failed attempts."
parent = "\n\n".join([
"原要求:保留已有结果和失败记录。Original requirement: retain results and failed attempts.",
"1. Inspect the evidence",
"Keep the original records available.",
"2. Compare the sources",
"Read the relevant sections before deciding.",
"3. Report the result",
"An independent list can start later:",
"7. A retained step\n42. The following step",
"A zero-based list:",
"0. Initial state",
"- Preserve uncertainty.\n- Preserve failed attempts.",
"```text\n9. This is literal code, not another list.\n```",
])
body = "请比较这次修改,并保留原话题中的限制。Compare this change against the original constraints."
request = identity_ref(self.observe()["provider_ref"], event["message_id"])
record = {"event": event, "profile": self.transport_ref, "request_ref": request}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ try {
await context.locator("summary").scrollIntoViewIfNeeded();
assert.ok(await page.locator("body").evaluate(node => node.scrollWidth <= innerWidth + 1));
await page.screenshot({path: resolve(output, "expanded-narrow.png"), animations: "disabled"});
await context.locator("blockquote ol").nth(1).scrollIntoViewIfNeeded();
await page.screenshot({path: resolve(output, "expanded-narrow-steps.png"), animations: "disabled"});
await context.locator("summary").click();
await page.screenshot({path: resolve(output, "default-narrow.png"), animations: "disabled"});
await page.evaluate(() => localStorage.setItem("loopx-pw-locale", "en"));
await page.reload();
await page.getByRole("navigation", {name: "Manager view"}).getByRole("button", {name: /^(Chat|Conversation)$/}).click();
await page.getByText("Reply and thread context", {exact: true}).waitFor();
await page.screenshot({path: resolve(output, "english-narrow.png"), animations: "disabled"});
const quote = context.locator("blockquote");
assert.deepEqual(await quote.locator("ol").evaluateAll(lists => lists.map(list => list.start)),
[1, 2, 3, 7, 0], "Paragraph-separated steps and independent lists retain their starting numbers");
assert.equal(await quote.locator("ol").nth(3).locator("li").count(), 2,
"Later source markers in one consecutive list do not split its sequence");
assert.equal(await quote.locator("ul li").count(), 2, "Unordered lists stay unordered");
assert.equal(await quote.locator("pre code").textContent(), "9. This is literal code, not another list.");
assert.deepEqual(errors, []);
assert.ok(!writes.some(path => /\/turns(?:\/|$)/u.test(path)), "Browsing cannot submit a Turn");
child.stdin.write("inspect\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export type MarkdownBlock = {startLine: number; endLine: number} & (
| {type: "code"; text: string}
| {type: "table"; headers: string[]; rows: string[][]}
| {type: "heading"; level: number; text: string}
| {type: "list"; ordered: boolean; items: string[]}
| {type: "list"; ordered: boolean; start?: number; items: string[]}
| {type: "paragraph"; lines: string[]}
);
type BlockContent = MarkdownBlock extends infer T ? T extends MarkdownBlock ? Omit<T, "startLine" | "endLine"> : never : never;

const UNORDERED = /^\s*[-*•]\s+(.*)$/;
const ORDERED = /^\s*\d{1,9}[.、)]\s+(.*)$/;
const ORDERED = /^\s*(\d{1,9})[.、)]\s+(.*)$/;

function tableCells(line: string) {
return line.trim().replace(/^\|/, "").replace(/(?<!\\)\|$/, "").split(/(?<!\\)\|/).map(cell => cell.trim().replace(/\\\|/g, "|"));
Expand Down Expand Up @@ -68,14 +68,15 @@ export function parseMarkdownBlocks(text: string): MarkdownBlock[] {
}
if (UNORDERED.test(line) || ORDERED.test(line)) {
flushParagraph();
const start = i, ordered = ORDERED.test(line), items: string[] = [];
const start = i, firstOrdered = line.match(ORDERED), ordered = firstOrdered !== null, items: string[] = [];
const pattern = ordered ? ORDERED : UNORDERED;
while (i < lines.length) {
const item = lines[i].match(pattern);
if (!item) break;
items.push(item[1]); i += 1;
items.push(item[ordered ? 2 : 1]); i += 1;
}
push({type: "list", ordered, items}, start, i);
const number = Number(firstOrdered?.[1] ?? 1);
push({type: "list", ordered, items, ...(number !== 1 ? {start: number} : {})}, start, i);
continue;
}
if (line.trim() === "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function MarkdownText({text, headingPrefix, headingLevel = 2}: {
if (block.type === "list") {
const items = block.items.map((item, itemIndex) => <li key={`${key}-${itemIndex}`}>{renderInline(item, `${key}-${itemIndex}`)}</li>);
return block.ordered
? <ol className="personal-md-list" key={key}>{items}</ol>
? <ol className="personal-md-list" start={block.start} key={key}>{items}</ol>
: <ul className="personal-md-list" key={key}>{items}</ul>;
}
return (
Expand Down
Loading