# Xpace Chat 0.11.0: Translation layer, phase 1 (read side by side) (17 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.10.4; nothing was removed or changed in the inbox, AI replies, follow-ups, leads or Sales Draft mode. The database only gains tables, so 0.10.4 opens a 0.11.0 database and the other way round (rollback safe).

- **Translation is OFF until an admin turns it on** (Settings > Basics > Translation). When on, every new message is translated once, in the background, into the languages your active staff read, and stored beside the original. It uses the same AI key, model and monthly budget as the rest of the app, and does nothing without a key.
- **Language detection** is local (script and English/Malay word lists, no AI call). Short or mixed chat is marked "unclear" and is not translated automatically; a person can still tap "Translate".
- **Two-line bubble.** Translation on top, the original smaller below. Customers default to translated-only (tap "Show original"); workers, outside people and internal groups default to both lines. Each person can change this under Me > Reading, and also pick their own reading language (otherwise the app language is used). A quick switch sits in the chat header.
- **"AI translated" tag** on every translated line, and **"Wrong translation?"** which records a report (with the original and the translation) that an admin sees under Settings > Translation and can mark as handled. Reports only show for rooms that admin may open.
- **Protected values stay unchanged.** Numbers, sizes, dates, times, prices, codes (for example SO-2411) and links are swapped for markers before the translator sees them and put back after. A translation that loses, repeats or invents a marker is refused and shown as failed.
- **A failed translation never blocks a message.** It is recorded as failed, the original stays as it was, and a "Try again" link is shown. No key, over budget or switched off: nothing is recorded and nothing is shown.
- **Translate once per language and reuse.** One row per message and language. A stored translation is never overwritten; only a failed one is retried, and only on request.
- **One swappable translation provider** (`src/translate/provider.ts`). Provided: Claude (your AI key) and a Demo provider (plainly fake text, for trying the screens without spending anything). Demo rows are replaced when a real provider is chosen.
- **tenant_id on every new record** (message_lang, message_translation, translation_flag, reading_pref).
- New API: GET/PUT /api/translate/config, GET/PUT /api/me/reading, GET /api/translate/flags, POST /api/translate/flags/:id/resolve, POST /api/rooms/:id/translate, POST /api/translations/:id/flag. GET /api/rooms/:id/messages gains `tr` per message and `reading` (old clients ignore both).
- Not in this build: phases 2-5, WeCom / personal WeChat relay, legal documents, translating what staff type before sending.
- Tests: 415 pass (14 new for translation). Version is now 0.11.0.

# Xpace Chat 0.10.4: AI Agents, phase 5 of 5 (lessons go into a NEW draft playbook version) (14 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.10.3 / 0.9.9; nothing was removed.

- **Keep no longer changes the live words.** In Teach the AI, "Keep" on a lesson (the weekly/connector queue, "Keep all", and "Keep this wording" on an edited draft) now puts it into a draft playbook version of Sales. The first Keep starts a new draft (for example 1.0.1) from the version that is live; later Keeps add to that same open draft. The toast names the version.
- The draft is like any other: Run tests, Compare with live (a new "Real replies added" section shows kept real replies), Make live only after the tests pass and a confirm. Editing it clears its test result.
- Kept real replies (examples) are stored in the draft and reach the saved real replies only when it goes live. Roll back takes out the ones that version added and leaves the ones a person saved.
- Every kept lesson is recorded in `lesson_items` (tenant_id, version, source, text, status in_draft / live / rolled_back).
- Auto-keep of wording lessons (the weekly switch) stays OFF as KY set it; when someone turns it on, it also only fills a draft. Model claude-sonnet-5-5 and all other settings are untouched.
- A lesson that only repeats what the live version already has makes no draft. A lesson that would make a text too long is refused and stays in the queue.
- Not changed: the one-off "Learn from my chats / website" save in Teach the AI (a person pressing Save on their own import) still saves straight into Teach the AI, and so does editing Teach the AI by hand.
- **Fixes from the independent (Opus) review of the whole build, all in 0.10.4:**
  1. A later lessons draft no longer drops the real replies an earlier live lessons version added (they are carried forward; an ordinary new draft from live carries them too). Roll back matches whole question + answer, so a person's own saved reply is never removed by mistake.
  2. Replies written by Claude through the connector now get the same code checks as the app's own AI before they may go by themselves (price, per-foot rate, discount, unknown amount, false "sent"). "RM150k" or "RM150 per foot" is no longer treated as the RM150 measurement fee.
  3. Roll back to a version that never passed the tests puts Sales back on Draft (and the send-by-itself switch with it); the message says why.
  4. A follow-up can no longer claim photos were sent (follow-ups carry no pictures).
  5. A lessons draft that is older than the live version is not extended; the next Keep starts a fresh draft from the live words.
  6. Keep on lessons that are already in the live playbook says so, and makes no empty draft.
- Known and left as is: (a) a playbook file uploaded by hand can carry the guardrail switches (price switch, hold times) into a draft; they show in Compare > Settings before anything goes live. (b) Turning on "send by itself" in Teach the AI still puts Sales in Auto at once (day-one behaviour of 0.9.9; the tests-first rule applies to the AI Agents Auto button and to Roll back).
- Tests: 401 pass (392 + 9 new; 2 older lesson tests updated). Version is now 0.10.4.

# Xpace Chat 0.10.3: AI Agents, phase 4 of 5 (code guardrails on every reply) (14 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.10.2 / 0.9.9; nothing was removed.

These rules are plain code, checked on every AI reply whatever the playbook says. They do not use an AI call.
- **Closing message or STOP = no reply.** When the customer's last message only closes the chat ("ok", "thanks", "noted", a thumbs-up, "谢谢", "terima kasih") and we did not leave a question open, the AI is not even asked: no draft, no cost, a "no reply" line in the Replies log. One "ok" right after our question still gets an answer (that is hesitation). STOP words are still handled before any AI work and the customer stays opted out. The "AI draft" button still works when a person asks for one.
- **Never a 3rd repeat of a question.** The code knows 8 kinds of question (name, budget, plan or size, area, key date, design, which parts, how it is used). A kind we already asked twice in the chat is cut out of the reply and logged as "repeat question" (counted in the weekly scorecard). If nothing else is left, the reply is kept but waits for a person.
- **Name rule.** The prompt asks for the customer's name once, as a courtesy line, in the first reply of a chat only. The chat remembers which questions were really sent. If the name was asked before (by the AI or a person) the question is cut out.
- **No price, rate or discount.** Any per-foot rate and any mention of a discount (except "we cannot offer a discount") holds the reply for a person, even when the Teach the AI price switch is off. A ringgit amount not in the fact sheet is held (as before). The approved RM150 measurement fee is allowed when the fact sheet carries it, and may now also go by itself in Auto (before, any amount waited).
- **Never says something was sent when nothing was** ("I have sent the quotation / photos"): held, unless pictures really go with that reply.
- **No laser or other edging talk** (laser, PUR, EVA, edge band, edging) unless the customer asked about it in their last messages; the sentence is cut out.
- Replies log shows these in plain words (English, Malay, Chinese).
- Behaviour changes to know: (1) a reply with RM150 used to wait for a person; now it is allowed (needs RM150 in the fact sheet). (2) A per-foot rate or discount in a reply is now held even if the price switch is off. (3) The AI's first reply of a chat now ends with a name courtesy line.
- Tests: 392 pass (379 + 13 new; 4 older tests updated for the RM150 change and for the closing message no longer reaching the AI). Version is now 0.10.3.

# Xpace Chat 0.10.2: AI Agents, phase 3 of 5 (playbook versions, Tests, Make live blocked until the tests pass, one-click Roll back) (14 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.10.1 / 0.9.9; nothing was removed.

- **Playbooks tab.** A playbook version is a saved copy of what you taught the AI (core rules, Sales module, fact sheet, quick replies, good chats, guardrail switches). Version 1.0.0 is the one imported from Teach the AI. New draft version (from the live one or from the current Teach settings, with a note), edit a draft, **Compare** any two versions, **Download** a version as a file (and upload one as a new draft). Once a version has been live it cannot be changed; make a new draft instead.
- **Make live** puts a version's words into Teach the AI. It is blocked until that exact version has passed the Tests, and asks for a confirmation. The API key, model, spending limit, rates and the send-by-itself switch are never part of a version, so KY's settings (model claude-sonnet-5-5, auto-keep of wording lessons OFF) cannot be changed by Make live or Roll back. Editing Teach the AI after going live shows a "differs from the live version" notice.
- **Roll back** (one click, with a confirmation) returns to the latest earlier version that was live and marks the current one as replaced.
- **Tests tab.** The 22 Sales cases of the Sales pack. 18 are written by the AI from the playbook and marked by a second AI call on the 10-item score sheet (0 to 2 each, out of 20), plus code checks for critical fails (price, discount, date or slot promise, false "sent", third repeat of a question, replying to a closing message). 4 cases (STOP word, salesperson just replied, name given, follow-up cancelled) run the app's own rules on a scratch copy. A version passes when all 22 ran, there is no critical fail and the average is at least 18/20. The cost is shown in RM before the run and you must accept it; a run that would go over the monthly budget is refused. Runs use the real AI and count in the monthly budget. One run at a time.
- **Auto mode needs a tested version.** In AI Agents, switching Sales to Auto is refused until the live version has passed. The send-by-itself switch in Teach the AI is unchanged.
- Notes for KY: (1) if the live Auto-send is ON, Sales starts in Auto, and Auto only sends replies the AI tagged with a kind, so more replies wait than before. (2) RM150 measurement fee must be in the fact sheet (Sales pack section 8) or the tests will flag it. (3) The "extra rules" limit is raised to 40,000 characters so the core rules and Sales module fit.
- Upgrade check: a fresh 0.9.9 data folder opened with 0.10.2 and then with 0.9.9 again starts cleanly both ways. Installs made on 0.10.0/0.10.1 get a go-live time added to 1.0.0 so it can be rolled back to.
- Tests: 379 pass (354 + 25 new). Version is now 0.10.2.

# Xpace Chat 0.10.1: AI Agents, phase 2 of 5 (the AI Agents screen, Shadow mode, Replies log, weekly scorecard) (14 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.10.0 / 0.9.9; nothing was removed.

- New **AI Agents** tab next to Teach the AI (needs the Settings right). Sales is live; Follow-up, Design and Support are shown as "Coming soon".
- Each agent has a mode: **Off** (no AI replies), **Shadow** (the AI writes in the background, the customer sees nothing, nothing waits for approval; the log keeps it next to what a person really sent), **Draft** (a person approves, as today) and **Auto** (asks to confirm). The Auto/Draft switch in Teach the AI and the Sales mode stay in step.
- "Which replies may go by themselves": one Auto/Draft switch per kind of reply (greeting, details, plan received, budget, "how much?", fact-sheet answer, process, samples, quote follow-up). "Anything else" (prices, payments, dates, complaints, unsure) is always a draft. The AI tags each reply with its kind; an untagged reply waits for a person in Auto.
- **Replies log**: one line per AI reply with filters (agent, kind, edited, result) and Download CSV (formula-safe). Shadow lines record what the AI would have said and what a person really sent; sent lines record whether the customer replied, opted out or went quiet.
- **Weekly scorecard** (7/14/30 days) per agent and playbook version: drafts, approved without edit, edited, rejected, sent by AI, held, repeated questions, stops, opt-outs, details per chat, price leaks (must stay 0), take-overs.
- Settings kept: model claude-sonnet-5-5 and auto-keep of wording lessons OFF are not touched. If Auto-send is ON when this version first starts, Sales starts in Auto so behaviour stays identical; otherwise Draft.
- Tests: 354 pass (340 + 14 new). Version is now 0.10.1.

# Xpace Chat 0.10.0: AI Agents, phase 1 of 5 (the foundation; nothing a customer receives changes) (14 Nov 2026)

TEST COPY ONLY until KY says go. Built on top of 0.9.9; nothing was removed.

- New tables (each with tenant_id): agents, playbook_versions, playbook_tests, test_runs, ai_reply_log, lesson_items. New chat fields: assigned_agent, last_question_field, already_asked_fields, ai_hold_until. All additive: 0.9.9 ignores them, so going back to 0.9.9 on the same data works (checked).
- On first start the Sales agent is created in DRAFT mode (as today) with playbook version 1.0.0 imported from the current Teach the AI settings (fact sheet, rules, quick replies, good chats, guardrail switches). The AI key, model and budget are not part of a version, so KY's model (claude-sonnet-5-5) and the auto-keep OFF setting are untouched.
- Every AI-written draft is logged (agent, version, model, tokens, cost in RM, scenario, checks that fired). When it is sent or rejected the log records the words that really left, who sent them (AI or person), and whether a person edited them.
- Chats show a small grey "AI · Sales" label in the list (internal only; the customer never sees it).
- Logging can never block a reply: if it fails, the draft is still made and sent as before.
- Tests: 340 pass (330 existing + 10 new). Version is now 0.10.0.

# Xpace Chat 0.9.9: the AI sends sample pictures, and staff can attach pictures and files (13 Nov 2026)

**Sample library.** 38 photos of our finished jobs (kitchen, wardrobe, wardrobe with study desk, TV console and display cabinet, shoe cabinet and storage, bathroom vanity) come with this version and are added to the library on first start. The library lives in the app: staff see it under the new **Pictures** button in every chat; an admin can add or remove photos there.

**The AI sends the pictures itself.** When a customer asks to see samples or past work, the AI says yes we have, says it is sending a few photos, and the photos go out right after its words (up to 4, mixed from different finished jobs, never the same photo twice to the same customer). If the customer did not say which area, it asks first. For an area with no photos it says the team will send some and hands over to a person. Pictures need a phone-linked number; on the official WhatsApp Business route the words go and the picture is reported as not sent.

**Staff can send pictures and files.** New **Pictures** (pick from the library) and **Attach** (a file from the computer or phone: JPG, PNG, PDF, Word, Excel, drawing files) buttons next to the message box. Pictures show in the chat as pictures, for what we send and what the customer sends. A pending AI draft that carries pictures says so.

Includes 0.9.8 (below).

----
# Xpace Chat 0.9.8: the AI never leaves the customer with nothing, and always asks for the next detail (13 Nov 2026)

**Send and alert.** When the AI wanted a person (the customer asked for one, a fact was missing), its reply used to wait for approval, so the customer got nothing until someone opened the app. Now its short reply still goes out, the lead is tagged "Needs a person", a note is written in the chat for staff and the salesperson gets an alert. A reply that mentions money still waits for approval. Teach the AI has the switch.

**A message that was only read is still answered.** After a salesperson replies in a chat the AI steps back for 2 hours, but it no longer leaves a new customer message hanging: if nobody answers it within 10 minutes (Teach the AI, 0 to 15), the AI answers.

**Always ask for more.** Until the quotation has what it needs, every reply ends with one question for the next detail: which parts they want done, how they use each part (cook heavy? adults or kids?), the design they like, special requests, the key date, the rough budget. The AI no longer flags a chat for a person because of something said earlier, or because a picture is waiting for the team, and it says "a team member will join" only once.

Includes 0.9.7 (WeChat assistant test), 0.9.6, 0.9.5 and 0.9.4 (below).

----
# Xpace Chat 0.9.7: WeChat assistant test (13 Nov 2026)

**Test only.** Settings > "WeChat assistant (test)": an admin scans a code with a WeChat account to link it to WeChat's own bot service. This is to find out what the service can do (groups, sending first, how long a chat stays open) before a WhatsApp-to-designer bridge is built. Nothing is sent to anyone by the test, and the sign-in token stays on the server. Only an admin sees the card.

Includes 0.9.6, 0.9.5 and 0.9.4 (below).

----
# Xpace Chat 0.9.6: leads named the CRM way (13 Nov 2026)

**Name + location.** When a customer gives their name, the lead is renamed from the phone number (or the WhatsApp profile name) to the name plus the location, for example "Jason Setapak". If the location comes later, the name follows. Teach the AI > "how a lead is named" sets the pattern ({name} and {area}). A name your staff typed, or typed when adding the lead, is never changed.

Includes 0.9.5 and 0.9.4 (below).

----
# Xpace Chat 0.9.5: we wrote first becomes a lead by itself; the AI no longer silences itself (13 Nov 2026)

**Fix: the AI went quiet after its own reply.** Since 0.9.3 an AI reply goes out as several short messages. The first ones came back from the phone and were recorded as "typed on the phone", so the "a person replied, stay quiet for 2 hours" rule switched the AI off after its own answer. Each message is now recorded the moment it leaves, and the app no longer listens to echoes of its own messages.

**The AI knows a picture or file arrived.** A customer's picture or file used to reach the AI as an empty message. It is now told one was sent, thanks the customer, says the team will look at it, and gives the next step. It still cannot see the picture itself.

**We wrote first.** When a salesperson sends an opening message from their phone to a new number, the chat becomes a lead by itself, kept by that salesperson. Leads > Where leads come in: each source can hold its "Opening message"; a match tags the lead with that source. With no saved opener, a first message that names the company still counts (and "小红书", "Facebook" in it pick the source). Someone the salesperson already chats with privately stays private. After an opener the AI may answer the customer's first reply.

**Open WhatsApp.** A link on the customer panel and in the Leads list opens WhatsApp with that customer, with the opener filled in when the chat is new.

Includes 0.9.4 (the "Waiting for this message" switch, no empty drafts, stronger model).

----
# Xpace Chat 0.9.4: an option for "Waiting for this message", two fixes (13 Nov 2026)

**"Waiting for this message".** Settings > Linked phone: a switch "Reply to the hidden id the customer wrote from". WhatsApp now knows many people by a hidden id; a reply sent to their phone number can show as "Waiting for this message" for 10 to 20 seconds first. With the switch on, the reply goes to the hidden id instead (and falls back to the phone number if that fails). Off by default: switch it on, send a test, and switch it off again if replies stop arriving. The card also shows how many customer messages came in by hidden id and by phone number.

**Fixes.** A reply the AI left empty no longer becomes an empty draft. A stronger AI model that refuses a forced reply form now works (the app lets the model choose the form).

----
# Xpace Chat 0.9.3: the AI knows when to stop (13 Nov 2026)

**A person replied: the AI steps back.** When a salesperson answers a customer, from the phone or from the app, the AI stops sending in that chat for 2 hours (Teach the AI: minutes, 0 = never). It still writes drafts for the salesperson. The customer panel says until when.

**No answer when none is needed.** A closing "ok", "thanks", 👍 or "will let you know" after we already gave the next step gets no reply, the way a person would leave it. The AI does not ask the same thing a third time.

**A no is a no.** When a customer says no / not now / went with someone else, follow-ups and sequences stop for that customer until they write again. A follow-up the AI judges wrong for the chat is not written at all.

Includes everything in 0.9.2, 0.9.1 and 0.9.0 (below).

----
# Xpace Chat 0.9.2: replies that sound like a person and keep the chat going (13 Nov 2026)

**New way of writing.** The AI now answers first, in short messages, asks only one question at a time and always ends with one easy next step, so a chat does not stop at "let us know". Asked to suggest, it suggests. When a customer hesitates ("hmm", "still thinking", "ok") it asks lightly what is holding them back. When they say no, it accepts and stops asking. Quick replies are still its base, but no longer pasted as a block of questions.

**Short separate messages.** An AI reply goes out as up to 3 short WhatsApp messages, the way a person texts, instead of one block. What staff type stays one message. The AI line ("replies may come from our AI assistant") is its own first message.

**Right language every time.** The app works out the customer's language from their own messages and tells the AI outright, so an English question is no longer answered in Chinese because the examples are Chinese. A short "ok" does not flip the language.

Includes everything in 0.9.1 and 0.9.0 (below).

----
# Xpace Chat 0.9.1: review follow-ups in bulk, one switch for automatic (13 Nov 2026)

**Review all.** Follow-ups > "Review all (n)": every follow-up the AI wrote on one screen. Read them, fix any wording, untick the ones you do not want, then "Approve and send" or "Skip" them together. They go out one by one at a human pace; anything that could not be sent says why on its own card.

**One switch.** Follow-ups (right side) > "Send AI follow-ups by themselves". Off (default): every follow-up waits for approval. On: clean ones go out by themselves; anything about money or that the AI is unsure of still waits. The switch no longer depends on "the AI sends its reply by itself", and it asks you to confirm before switching on.

Includes everything in 0.9.0 (below).

----
# Xpace Chat 0.9.0: AI line, saved customer details, follow-ups from the chat, group waiting list, design-team list, downloads (13 Nov 2026)

**The customer is told an AI may reply.** The first automatic reply to each customer starts with one short line (again after 30 days), in the customer's language. Your own wording can be typed in Teach the AI. If a customer asks, the AI says honestly that it is an AI assistant and that the team can take over.

**Customer details save themselves.** Name, area, home type, what they want, sizes, budget, timeline, notes and a short summary appear on the customer panel as the chat goes on, and on the Leads page (searchable). Anything a person types is never changed by the AI. The AI may ask the customer's budget; it still never states our prices.

**Follow-ups written from the conversation.** When a customer goes quiet after we wrote, the AI writes a follow-up from where the chat stopped, and the count starts again after every customer reply. Teach the AI > "Send follow-ups written from the conversation by themselves" sends clean ones automatically (never in quiet hours, never about money, never to a chat a person took over). With a linked phone these no longer stop after 24 hours.

**Customer groups: who is waiting.** For WhatsApp groups with a customer in them: Team chat lists groups where the customer is waiting for us (default 4 working hours) or we are waiting for the customer (default 24 hours), with one alert per open point, a Settled button and a ready nudge. Hours are set in Settings.

**To design team.** Follow-ups > To design team: customer feedback for the design team, written in Chinese by the AI (or added by staff with "Pass to design team"), with the customer's pictures and files. Copy, paste into WeChat, tick as sent. Nothing is sent to WeChat by the app. Files up to 12 MB are now kept.

**Downloads.** Leads > Download: the lead list with details, or the chat messages, as a file for Excel. A salesperson only gets their own leads. "Download this chat" on the customer panel. Every download is written in the audit list.

----
# Xpace Chat 0.8.7: the chat window stays inside the screen (13 Nov 2026)

**Fix.** In an open chat the whole page used to grow as long as the conversation, so the text box ended up far down. Now the messages scroll in the middle and the text box stays at the bottom of the screen, on desktop and on a phone (like the Claude window). On a phone the footer line is hidden inside a chat so the page does not scroll.

----
# Xpace Chat 0.8.6: the app stays inside the screen (13 Nov 2026)

**No more scrolling the whole page.** On a phone the Inbox list now fits between the top bar and the bottom menu and scrolls inside its own box (it used to grow as long as the chat list and scroll the whole page). The Leads, Bulk send and Audit tables also scroll inside their own box with the column heads staying on top. Uses the real visible screen height on phones, so the browser address bar no longer pushes things off screen.

----
# Xpace Chat 0.8.5: customers who already sent their layout are not asked again (13 Nov 2026)

**Floor plan received.** When a customer sends a picture or a file, the lead is tagged "Floor plan received" by itself. The Enquiry follow-up sequence (and any sequence for the enquiry stage) never starts for a tagged lead, so nobody who already sent the layout gets "can you send your layout plan?". Remove the tag by hand if you want them back in.

**Fix.** The "tags" condition of a follow-up sequence is now saved from the Sequences page (it was dropped before).

**Long follow-ups.** Nothing to change in the app: sequences already allow up to 12 messages and gaps up to a year. The live sequences are now set to run about 6 months.

----
# Xpace Chat 0.8.4: price questions get a real answer, weekly learning by itself, backups (13 Nov 2026)

**Price questions are answered, not parked.** The AI still never states a figure, but it now replies itself: every job is custom, asks for the missing details and says we will prepare the quotation. Only a reply that contains a money amount is held for a person.

**Learning runs by itself.** Teach the AI > Lessons to review > "Learn by itself every Sunday 22:00" (day and time can be changed). It reads the last 7 days of every salesperson's chats with the AI key. Wording lessons (real replies, quick replies, questions for new enquiries) can be kept automatically; facts, rules and anything about money always wait for the owner.

**Backups.** A full copy of the database is made every night after 03:00 into the data folder (backups, last 14 kept). Settings > Backups: "Back up now" and Download.

New: 2 tests (total 292).

---

# Xpace Chat 0.8.3: the learning loop (13 Nov 2026)

**New: Teach the AI > Lessons to review.** What the AI could learn from the last 7 days of real chats (facts the team stated, real replies, quick replies, rules) waits in a queue. Nothing changes until the owner presses Keep; lessons that mention money are marked and are not included in "Keep all". Replies the AI sent by itself are not learned as the team's wording. Phone numbers, emails and links are hidden.

Two ways to fill the queue: the button "Learn from the last 7 days now" (uses the AI key), or Claude on the owner's own plan through the connector (two new connector tools: get_recent_chats_for_learning and propose_lessons; the Claude link must allow changes). New: 1 test (total 290).

---

# Xpace Chat 0.8.2: no price talk, AI through the connector (MCP), no daily limit (13 Nov 2026)

**The AI does not talk about prices** (new switch in Teach the AI, on by default). It never gives a price, fee or ringgit amount; a price question gets a short "our team will get back to you" line and goes to a person. Any reply containing a money amount is held for a person.

**AI connection: access key or connector (MCP).** Teach the AI > "Which AI writes the drafts" has a new choice, "Claude through the connector (MCP), no key". The app then drafts nothing itself; replies Claude writes through the connector follow the same rules, and are sent by themselves when "Let the AI send its reply by itself" is on. Replies come only while Claude is running, so they are not instant.

**Removed: the limit of 15 automatic replies per customer per day.**

New: 2 tests (total 289).

---

# Xpace Chat 0.8.1: the AI can send its reply by itself (13 Nov 2026)

**New switch: Teach the AI > "Let the AI send its reply by itself".** After the wait (8 to 30 seconds) a clean AI reply goes out without anyone pressing Approve. A reply the AI is unsure about (a price not in the fact sheet, a topic for a person, a failed draft) still waits for a person. It does not send in a chat a person took over, does not answer an older message when the customer wrote again, sends at most 15 automatic replies to one customer in a day, and obeys the pause switch and opt-outs. If the host restarts the app during the wait, the clock sends the reply within about a minute. Off by default. New: 4 tests (total 287).

---

# Xpace Chat 0.8.0: Leads page (tags, groups, tick-many assign), lead intake links, personal phone fixes (13 Nov 2026)

**New: Leads page.** Every lead in one list with filters (search, stage, tags, area, where it came from, salesperson, not assigned, no reply for N days). A filter can be saved as a group. Tick many leads, then add or remove a tag, give them to one person, share them out in turn, or change the stage.

**New: tags.** A lead can carry many tags. A tag can have a rule (words in the chat or notes, area, source) and is then added by itself. Tags show on the customer panel in the Inbox, can be a condition of a follow-up sequence, and can be the audience of a bulk send.

**New: where leads come in.** One entry point per source (Xiaohongshu, Facebook, website...). Each gives a public form link and a webhook address. New leads are de-duplicated by phone, shared out by the assignment rule in Settings, and tagged.

**Fixed: linking a personal phone again no longer asks its owner to agree again** (incoming messages were dropped until they did). Stop on the Me page still clears it.

**Fixed (privacy): WhatsApp groups on a personal phone no longer appear in Team chat.** They are listed only for the phone's owner, nothing in them is recorded, and the owner presses Show for the work groups the team should see. Groups already pulled in are hidden once by this update (their old messages are kept but not shown).

New: 6 tests (total 283). New database tables: tag, contact_tag, lead_group, lead_source; one new column room.hidden. Repeat-safe, nothing removed.

---

# Xpace Chat 0.7.7: replies you type go out at once (13 Nov 2026)

**Faster:** a reply a person types is no longer held back by the "human pace" wait (3-8 seconds plus typing time) or by automatic messages in the queue; only automatic messages keep that pace. The Send button now shows on desktop too, the text leaves the box immediately and shows as "Sending…" in the chat (it comes back if it fails), and the Draft button shows "AI is writing…" while the AI works, so you can keep typing.

---

# Xpace Chat 0.7.6: replies typed by staff always send; team messages reach the group (13 Nov 2026)

**Fixed: a salesperson (KY) typed a reply and it was "not sent" while Admin's went out.** A typed reply was treated like an AI draft that needs an approver, and only the chat's salesperson (or a manager) counted. A reply you type yourself now always sends (you can only open chats you may see). 

**Fixed: team-chat message "not successfully sent" to the WhatsApp group.** When the group's number had been removed, the message was only saved in the app. It now uses the company number or the sender's own phone, and the screen says plainly when it did not reach the group.

---

# Xpace Chat 0.7.5: quick replies by keyword (12 Nov 2026)

**New: quick replies by keyword.** Write quick replies as `keyword|wording` (Teach the AI). In a chat, type `/keyword` (a list of matches appears) or just the keyword, and press Enter: the full wording is filled in, press Enter again to send. 

**Found live: customer replies were dropped after the phone was linked again.** A new link of a personal phone must be agreed by its owner (Me > Agree) or the phone made a company phone, otherwise incoming messages are dropped on purpose (14 were). Steps in GO-LIVE-STEPS.txt.

---

# Xpace Chat 0.7.4: "Waiting for this message" on the customer's WhatsApp Desktop (12 Nov 2026)

**Fixed (stronger): messages that show on the customer's phone but "Waiting for this message" on their desktop.** WhatsApp asks the sender to send a message again when a device cannot open it. 0.7.1 answered from memory only, which is lost whenever the host restarts the app. Now sent messages are also kept in a small file (sent-cache.json in the data folder, last 300) and the retry counter WhatsApp expects is kept too, so the resend works after a restart. If it still happens for one customer, they open WhatsApp Desktop once and wait a minute, or the number is linked again from Connect.

---

# Xpace Chat 0.7.3: quick replies open at once (12 Nov 2026)

**Fixed: the Quick replies button was slow.** It fetched the whole Teach-the-AI page from the server on every click (and staff without the Settings right got an empty list). The list is now loaded ahead when a chat opens, kept in memory, and the button opens instantly; a fresh copy is fetched quietly in the background. New light endpoint GET /api/quick-replies for every signed-in person. New test (total 276). Includes the 0.7.2 fix.

---

# Xpace Chat 0.7.2: fix "Not sent" for chats pointing at a removed number (12 Nov 2026)

**Fixed: "Not sent. No WhatsApp number is connected" although the personal phone is linked.** An older chat could still point at a WhatsApp number that had since been removed. The send now ignores a number that no longer exists, clears the stale link on the chat, and sends from the sender's own linked phone (or the company number). Drafts waiting to be approved are treated the same way. New test (total 275).

If the phone itself shows "disconnected" on Connect, press "Reconnect now" (or scan the code again) once.

---

# Xpace Chat 0.7.1: follow-up sequences, sending from a personal phone, message resend (12 Nov 2026)

**Follow-up sequences** (Follow-ups & scheduled > Sequences). Write a list of messages once; when a lead meets your conditions the sequence starts by itself, waits the hours or days you set, and stops the moment the customer replies, writes STOP, the lead is closed, or moves to another stage. You choose the conditions yourself: stage, area, where the lead came from, salesperson, words in the chat or notes, minimum number of messages from the customer, and "agreed to offers". "Who would join now" shows which leads match before you switch a sequence on. Each sequence either prepares drafts for a person to approve, or sends by itself; and it sends from the number the customer wrote to, the company number, or the salesperson's own phone. A daily limit for automatic messages (default 40), quiet hours, "a person took over this chat" and the pause switch are all respected, and at most five messages go out per minute. Enquiry and Quotation-sent each get their own sequence; two starter examples (switched off, no prices, no free site visit) can be added with one button. The old follow-up ladder stays and steps aside for a lead while a sequence is writing to it.

**Fixed: "Not sent. No WhatsApp number is connected" when only a personal phone is linked.** A chat with no number attached now leaves from the sender's own linked phone (the clock uses the salesperson's phone; an admin may use the one linked phone). Nobody can send from a colleague's phone otherwise.

**Fixed: "Waiting for this message" on the phone.** The app can now answer WhatsApp's request to send a message again (it keeps the messages it sent recently).

**Fixed: raw label text (lrn_title, tx_banner) after an update.** After each new version the app fetches its own files fresh once and reloads, so old and new screens never mix.

New: 11 tests (total 274). One new database section (three tables; repeat-safe, nothing removed).

# Xpace Chat 0.7.0: learn from your chats (12 Nov 2026)

Teach the AI has a new first card, "Learn from your chats". Choose WhatsApp chat files (a .txt, a .zip, a zip inside a zip, or a whole folder) and optionally type the company website. Phone numbers, emails, links and account numbers are hidden first. The AI (your own key, counted in the monthly budget) suggests facts, real customer-and-reply pairs, quick replies, how-we-talk rules, never-promise items, hand-over topics and the questions to ask a new enquiry. Each suggestion can be edited, un-ticked or deleted; only what is kept is saved, and nothing is ever sent to a customer from this card.

Also new:
- Drafts sound like the team: the AI is shown the saved real replies most like what the customer wrote, and is told to write like a person, react to the customer's own words, and never state a price.
- New enquiries: the AI asks for what is still missing (what to build, area, layout or sizes, key date, photos), a couple of questions at a time, and says it will check with the team when something is not in the fact sheet.
- Lessons from edited drafts: wording staff changed before sending can be kept as a real example for everyone.
- Reply delay: automatic replies now wait 8 to 30 seconds (never more than 30) before sending; both numbers are in Teach the AI section 5.
- Saved real replies can be reviewed and deleted.

No database change (the examples are stored as a setting), no new dependency. Website reading refuses private addresses. Test count: 263.

# Xpace Chat 0.6.5: the private tray is easy to find (12 Nov 2026)

On a personal phone, a message from a number that is not a customer yet waits in the private "Not sorted" tray. That tray was only reachable from the Me page, so a working phone looked empty. Now the Inbox shows a banner "N chat(s) are waiting in your private tray" that opens it. Connect also explains the case where a personal phone has no owner chosen (before it read "so Nobody yet must agree first"). No database change, no new dependency.

# Xpace Chat 0.6.4: one-click password reset from the email (12 Nov 2026)

The password email now has a link. Click it, type a new password, and you are signed in: three actions (ask, click, new password) instead of copying a code back. The 6-digit code is still in the email (and works on the "Forgot password?" page) if the link does not open. The link carries the email and the code after the # so neither reaches a server log; it works once and for 15 minutes. If it has expired the page says so and offers a new code. No database change, no new dependency.

# Xpace Chat 0.6.3: updates show at once, no stuck "Loading" (12 Nov 2026)

One fix on top of 0.6.2. Before, the browser could keep the old screen files for up to an hour after an update and mix them with the new ones, so the page stayed on "Loading". Now the browser checks for new files every time (a quick "nothing changed" answer when there is no update). Nothing else changed; no database change, no new dependency.

# Xpace Chat 0.6.2: password code by email, one Follow-ups & scheduled page, clear "personal phone" help (12 Nov 2026)

Built on 0.6.1 from KY's instruction. Nothing was removed. No database change and no new dependency (the email sender is built in), so NPM Install can be skipped on update.

1. **Password code by email.** Settings > Basics > "Email for password codes": mail server, port, connection, mailbox login and password, send-from address (for Build Xpace: reset@buildxpace.com on mail.buildxpace.com, SSL, port 465). Save, then "Send a test email to me". When email is on, "Forgot password?" emails the 6-digit code (in the person's language: English, Malay or Chinese). If the mail server is down or email is off, the code still goes to WhatsApp or to `password-reset.txt` in the data folder, so nobody is locked out. The mailbox password is stored sealed in the database and is never sent back to the browser. Staff need their email saved in Settings > Staff.
2. **Follow-ups and Scheduled are one page.** One menu entry "Follow-ups & scheduled" with two tabs. All functions of both pages are unchanged; the old #scheduled link still opens the Scheduled tab.
3. **"Personal number, owner has not agreed" explained.** A phone marked "This is a personal phone" records nothing until its owner agrees (a privacy rule, kept). Connect now says so in plain words next to that phone, shows the Agree box to the owner when they are signed in, and gives admins a one-click "Make it a company phone" (with a confirm) for when it is really the company's phone. The inbox hint wording is clearer.
4. Tests: 251 pass (241 old + 10 new: SMTP login and send against a test mail server, header-injection safety, email-first reset with fallback, settings and test email rights, merged page, Connect help); lint and build clean; browser click-through at 1280 and phone size. A real mailbox and a real phone could not be tested here.
5. **Not done:** an emailed reset link (the 6-digit code is emailed instead).

# Xpace Chat 0.6.1: forgot password, show-password eye, change password, footer on every page (12 Nov 2026)

Built on 0.6.0 from KY's instruction. Nothing was removed; sending, Connect, Scheduled, the Claude (MCP) connector, the API key and the CRM link are unchanged. No database change and no new dependency, so NPM Install can be skipped on update.

1. **Forgot password.** The sign-in page has "Forgot password?". Type the email, get a 6-digit code, type the code with a new password, and you are signed in. The code works for 15 minutes and once only. Where the code goes: to the person's own WhatsApp from a linked company phone, when the person has a WhatsApp number saved (Settings > Staff) and a company phone is linked; otherwise it is written to `password-reset.txt` in the data folder (the same place as `admin-password.txt`) and removed once used. The page gives the same answer for a real and an unknown email, so nobody can test which emails have an account. Limits: one code a minute and five an hour per person, five wrong tries per code, and a brake per address. "Pause all sending" also holds the WhatsApp route (the file is used instead). The code message is never filed as a customer chat.
2. **Show password (eye).** Every password box has an eye button: sign-in, new password, change password, the staff form, and the key boxes on Connect, Apps and Teach the AI. It is added by itself to any password box, so new screens get it too.
3. **Change password.** Me page > Change password (asks for the current one; other devices are signed out). Before this there was no screen to change a password at all, although Help and the go-live steps said there was.
4. **Admin sets a password.** Settings > Staff > Edit now has "New password" (empty keeps the current one) and "WhatsApp number (for password reset codes)". The person's other devices are signed out.
5. **Footer on every page.** "Xpace Chat 0.6.1 · Developed by Build Xpace Sdn Bhd" at the bottom of every page, signed in or not, desktop and phone. This was asked for on BUI-73 and was missing from 0.6.0. The version still comes from package.json; the header version stays.
6. **New API:** `POST /auth/forgot {email}`, `POST /auth/reset {email, code, password}`, `POST /auth/password {current, password}`. Activity log shows each in plain words.
7. Tests: 241 pass (233 old + 8 new); lint and build clean; browser click-through at 1280 wide and on a phone size (sign-in eye, forgot password with a wrong and a right code, change password, staff form, admin-set password, footer on all 12 pages, no sideways scroll). Malay and Chinese wording is a draft for a native check.
8. **Not possible / not done:** a reset link by email. The app has no email sender, and adding one means a new dependency and SMTP settings for every company. Say the word and it can be added as a second route.

# Xpace Chat 0.6.0: live release, no test mode, WhatsApp phone + Meta API, scheduling, tenant-ready, plain words (BUI-74, 12 Nov 2026)

Built from KY's instruction on BUI-74. Test mode and the Go live button are removed (by instruction); nothing else was removed. Not deployed; KY uploads.

1. **No test mode.** A new install is live from the first start. The checklist on Connect is only guidance ("3 things left to set up"). An update from 0.5.0 switches an install that was in test mode to live by itself. Anything that was scheduled or bulk-sending as practice is put on hold (scheduled drafts go back to "waiting for approval", running bulk sends are paused), and every admin sees one plain notice on the first sign-in saying so. The only developer switch is the server setting `XC_DRY_RUN` (records instead of sending); it is not in the app.
2. **Two ways to connect WhatsApp, both live, per number.** Phone scan (survives restart and idle sleep; clear "phone disconnected, scan again"; plain explanation for "scanned but no chat window") and Meta Cloud API (Business Account ID, Phone Number ID, token and webhook verify token pasted in the app; webhook address with a copy button; template messages outside the 24 hour window; a 3 to 6 step guide on the page). A tenant picks phone, Meta or both for each number. Inbox, Bulk send, Follow-ups and scheduling work the same on both.
3. **Scheduling.** Send later on any reply, bulk send at a set time, follow-ups that fire live. All of it is stored in the database and survives a restart. New "Scheduled" page lists everything waiting, with change time, send now and cancel. Tenant time zone in Settings (default Malaysia, UTC+8); the calendar and every shown time use it.
4. **Ready for tenants (SaaS).** One plain API key per tenant (Apps page, "Look only" or "Allow changes", shown once, can be reset) for other AI tools at `/api/ai/v1`, next to the Claude (MCP) connector that stays as before. Neither can message a customer. Both are explained in Help. Holding several tenants in one install is NOT small (30 tables without a tenant column), so it was not started: the plan is in NOTES.md and the question is on BUI-74. Sign-up and billing are not built.
5. **Plain words pass.** Every page starts with one line on what to do next; setup, Connect, Scheduled, Help, Settings, Teach, Team and the older pages were reworded in everyday English; the new Help page walks the whole path. All fixed text exists in English, Malay and Chinese (a test fails if one is missing or a placeholder differs).
6. **Safety fixes from the Opus review (before packaging).** (a) A message can no longer be sent twice when two people press Send together, or a person and the clock act on the same scheduled message: it is claimed first. A send cut off by a restart goes back to a person as "check the chat, then send again", never sent again by itself. (b) The emergency stop (Settings, pause all) now also stops a person pressing Send in the Inbox; the Send box says so; a bulk send pauses mid-batch without losing anyone from its list. (c) The switch to live is one all-or-nothing step, so a restart half way cannot leave practice messages armed. (d) Practice messages put on hold at the switch now show in Scheduled as "On hold" with "Set a time" or "Cancel" (before, the notice pointed to an empty page). (e) A bulk "send at a set time" must be a real time ahead of now; one whose time passed while waiting for approval is refused instead of going out at once. (f) Error messages from the server (for example "not allowed", "too soon", "no connected number") now show in plain words in the chosen language instead of an empty message; the Inbox read-only line is also plain words. (g) The offline cache no longer keeps customer photos; leftover test-mode wording removed from the public text list.
7. Tests: 233 pass (202 old + 31 new); lint and build clean; clean unzip, install and start checked; browser click-through at 1280 and 390 wide (144 checks). Malay and Chinese wording is a draft for a native check. A real phone scan and a real Meta account could not be tested here. No new dependency and no database change, so Run NPM Install can be skipped on update.

# Xpace Chat 0.5.0: calendar date picker + "linked but no chats" help (BUI-68, 11 Nov 2026)

Built from KY's comment on BUI-68. Nothing was removed. Go live, sending, the Connect page, the Claude (MCP) connector and the CRM link are unchanged. Not deployed; KY uploads and an admin presses Go live.

1. **Calendar to pick a date.** Everywhere the app used to ask you to type a date and time, it now opens a small calendar: Bulk send ("Send at a set time", with a Change button), Inbox ("Send later") and Follow-ups (new "Pick another day" next to "Send tomorrow 10:00"). Month grid starting Monday, hour and minute in 5-minute steps, quick buttons for tomorrow 10:00 and next Monday 09:30, past times refused, keyboard (arrows, PageUp/PageDown, Enter, Esc), month and day names in English, Malay or Chinese, a bottom sheet on a phone. It also fixes an old fault: the typed default time was shown in UTC, which is 8 hours off in Malaysia. Settings "On leave until" is a plain date and was left as it is.
2. **WhatsApp scanned but no chat shows.** Not reproducible without a real phone, so this build makes the reason visible instead of guessing. What is known: after you scan, old chats from the phone are not copied in (by design), so the Inbox stays empty until a customer sends a new message; an "own number" that its owner has not agreed to drops every message on purpose; messages from non-customers go to the private Not sorted tray; and WhatsApp sometimes hides a sender's phone number (a hidden id), which could not be matched. New: each linked phone counts what became of its messages (counts only, no text), the Connect page shows a plain sentence under each phone, and an empty Inbox shows a card saying why with a link to Connect. Hidden-number senders are now matched when WhatsApp gives the number in any of its fields, and the number is remembered for next time. New `GET /api/link-health`.
3. **Claude (MCP) connection.** Already in since 0.4.0: Connect apps > Other accounts > Claude. Unchanged and re-checked.
4. **Open question for KY:** should the app import recent chats from the phone when it is first linked? Today it does not (privacy: only messages after the scan). That needs KY's yes because it brings in old private chats.
5. Tests: 202 pass (195 + 7 new); lint clean. English, Malay and Chinese wording is a draft for a native check. No database change, no new dependency, so NPM Install can be skipped on update.

# Xpace Chat 0.4.2: version shown clearly + Test mode explained (BUI-68, 11 Nov 2026)

Same code and behaviour as 0.4.1. Only wording and display changed. Go live, Back to test mode, sending, the Connect page and every other function are untouched. Nothing was removed. Not deployed; KY uploads.

1. **The version is on every screen.** A small "0.4.2" sits next to the Xpace Chat name in the top bar of every signed-in screen (desktop and phone), "Xpace Chat 0.4.2" is at the bottom of the Me page, and the sign-in page shows "Xpace Chat 0.4.2" under the Sign in button.
2. **The number can never go stale.** It is read from `package.json` when the app starts (`src/core/version.ts`). The same number is in `/api/health` (new `version` field), the new open `/api/version`, `/api/me`, and the paired-app handshake (as before). A test fails if they disagree.
3. **"Test mode" now says what it means.** The tag reads "Test mode · nothing is sent" (just "Test mode" on a phone) and has a "?". Pressing it opens a short box: nothing is sent to customers yet, approved replies are only recorded, and to start sending an admin presses Go live on the Connect page, which stays switched off until every setup step there is green. Admins get an "Open Connect > Go live" button; other staff are told to ask an admin. Esc, Close or a click outside shuts it. English, Malay and Chinese (the Malay and Chinese wording is a draft for a native check).
4. **Note:** the old 0.4.1 screens had no version in the Connect apps footer (only in the paired-app data), which is why it was hard to find. It is now in the places above.
5. 195 tests pass (191 + 4 new); lint clean; checked by hand in a browser at 1280 and 390 wide (sign-in, header on every main screen, popover open/close/Esc/outside click, link to Connect, Go live still disabled, Me page, Malay and Chinese, a salesperson without the Connect right). No database change, no new settings, no `package.json` dependency change, so NPM Install can be skipped on update.

# Xpace Chat 0.4.1: go-live build (BUI-61, 9 Nov 2026)

Same code as 0.4.0 (which passed the real-Perfex TEST run, BUI-43: GO). Putting it live still needs KY's own yes, and KY uploads it. The package is not marked TEST.

## 0.4.1: three small screen fixes, nothing else
1. **"nullnull" on the linked-app card** (seen after a code was typed or shown): two empty lines were written to the page as the word "null". Fixed in `web/views/apps.js` (`linkCard`).
2. **"undefined" on the Teach the AI strip** (the six setup chips on the Connect page): the chips had no names. Names added in `src/api/admin.ts` (Fact sheet, WhatsApp linked, Salespeople and spend limit, AI key and model, Test draft tried, Gone live).
3. **Not changed:** the "Look only" hint on the Apps tab. It shows what the CRM may do inside Xpace Chat; the line under it shows what the CRM lets Chat do. The two sides are independent by the contract (v1.1 section 6), so it is not stale, only easy to misread. A wording change needs KY.
4. Version number 0.4.0 to 0.4.1 (shown to paired apps). 191 tests pass (189 + 2 new for the two fixes); lint clean; hands-on browser check of both fixes on a test rig.

# Xpace Chat 0.4.0 (earlier build): Claude (MCP) connector in the Connect page (BUI-45, 7 Nov 2026)

**This is a TEST build. It has not been put live and nothing in it sends anything to customers.** Putting it live needs KY's separate yes. The 0.3.0 leads path to the paired CRM is unchanged.

## 0.4.0: the Claude card is now a working connector
Contract: BX-PAIRING-CONTRACT-v1.1 (`assistant_key` card). Nothing was removed.
1. **A real `/mcp` endpoint** (MCP over Streamable HTTP, plain JSON, stateless): `initialize`, `tools/list`, `tools/call`, `ping`. The key is in the address (`/mcp/<key>`) or a Bearer header. A bad key is 401. Tested with the official MCP TypeScript SDK client (retest-0.4.0.md).
2. **The Claude card** (Connect apps > Other accounts) goes from "Coming soon" to Connect. One click makes a key. The address is shown once with Copy and the "Add custom connector" steps, then hidden for good (only a sha256 is stored; never logged, never in audit rows). Reset makes a new key and kills the old one. Disconnect removes it.
3. **Access follows the link level.** Look only (default): 7 read tools. Look and change (needs the second confirm click): also `create_lead` and `create_draft_reply`. Lowering takes effect on the next call.
4. **Nothing is ever sent to a customer from MCP.** `create_draft_reply` writes a pending draft ("Draft from Claude") that a person must read and send in Xpace Chat. A static test fails the build if MCP code touches a send path. `create_lead` follows the normal Quick add rules (and queues the lead, not a message, to a paired CRM, exactly as a hand-added lead).
5. **Claude acts as the admin who pressed Connect**: only customer conversations that person may see; no private notes, internal rooms, staff contacts or tray; phones partly hidden. Tool replies tell Claude that customer text is data, not instructions.
6. **Fixed plain sentences** for paused, key rejected and unreachable; "Waiting for Claude..." (not an error) until Claude first calls. Test and Reset/Disconnect work and write `link.*` audit events; every tool call writes `mcp.<tool>` (ids only).
7. **EN / MS / ZH text** like the other cards. The MS and ZH wording is a draft for a native check.
8. **Review fixes (Opus, opus-review-0.4.0.md, no must-fix found):** a phone search can only match the digits the mask already shows (opening digits or last 4), so it can no longer be used to guess the hidden digits one try at a time; `create_lead` no longer names a contact the connecting person may not see; tool calls (not just requests) are budgeted at 40 a minute per key, so one key cannot hold the inbox down; the customer count is exact (no 2000 cap); pages on another website are refused (Origin check); a stray GET no longer flips the card to Connected; the key stops working if the connecting person loses the Connect right; replies are compact and capped at 1 MB; the "customer text is data, not instructions" reminder is inside every conversation/lead reply; the bad-key limit is separate from the pairing one.
9. Other Connect behaviour is unchanged (189 tests: 161 before + 28 new).

**Open, not changed (KY to decide):** the three fixed sentences for paused / key rejected / unreachable are the contract's wording ("Claude no longer accepts this link", "We can't reach Claude"), but for this card the checks are about Xpace Chat itself (its own web address, the connecting person being switched off, Chat paused). Rewording needs a contract decision. Also: the key sits in the address path, so hosts should not log request addresses for `/mcp` (Reset makes a new key if a log leaks).

Known limits: see report-0.4.0 (not-tested list).

# Xpace Chat 0.3.0 TEST: Connect apps (pair-1) release notes (7 Nov 2026)

**This is a TEST build. It has not been put live and nothing in it sends anything to customers.** Putting it live needs KY's separate yes.

## 0.3.0: new leads go to the paired CRM (BUI-42, KY decision in BUI-21)
Contract: BX-PAIRING-CONTRACT-v1.1. Nothing was removed. TEST only: not deployed, no live data, nothing sent to customers.
1. **With a Connected CRM link, leads and the staff list go through the paired CRM address** (`/bx_integration_api/staff`, `/sources`, `POST /leads`) with the link key (stored encrypted, never in logs, audit or the lead table). Staff come in from the CRM; new leads go out. Without a paired CRM nothing changes: the old hand-made Perfex connector still works as before (its tests are kept as the regression) and no lead is queued.
2. **Look only / Look and change is respected.** A new lead needs Look and change. If the CRM says Look only, Chat says so in a plain sentence, does not send, and keeps the lead waiting. The card now also shows what the CRM lets Chat do ("Xpace CRM lets Xpace Chat look only").
3. **Same plain sentences as the Test** for paused (402, 423 or paused:true), key rejected and unreachable, shown on the CRM link card (amber, with a "Send now" button) and on the chat's contact panel.
4. **No duplicate leads; nothing lost silently.** The module has no retry key, so Chat tracks it: a row is written "sending" BEFORE the request. A certain failure (CRM down, paused, key refused, 4xx, busy) waits and goes again by itself, in order. An unclear one (timeout, dropped connection, server error with no message) may already be in the CRM, so it is NOT sent again by itself: it waits for a person, who gets "Send again" with a duplicate warning, or "It is already in the CRM". One run at a time, a claim on each lead, and an app restart in the middle of a send also lands on "unclear". A CRM that keeps refusing one lead is left alone after 5 tries until someone presses Send now.
5. **Which leads are sent:** every new lead from the moment the link is Connected (first WhatsApp message, Quick add, a not-sorted number turned into a customer). Leads that already existed before pairing, and the CSV importer, are NOT sent automatically: Chat cannot read the CRM's lead list, so a blind back-fill could put leads there twice. Each such chat has a "Send to CRM" button. A lead that was waiting when the link was lost goes after re-pairing.
6. **One-way, by the module's design:** leads made in the CRM and stage changes made there do not come back into Chat on a paired link (the old connector pulled them). Chat only adds leads.
7. **Disconnect:** the link stops sending, the notices go, new leads stay in Chat only, and the old manual Perfex connector card is available again.
8. **Review fixes (Opus, opus-review-0.3.0.md):** failures before the form token are certain not unclear; a busy CRM (429) is a wait; a lead sent to a different CRM address is not taken for one in this CRM; the CRM staff list (it includes people who left) can never switch off an admin's Chat login; a failed write-back after a sent lead is retried and, if it still fails, held as unclear; the toast and card count all unsent leads; tray customers are queued; new texts in English, Malay and Chinese.

**Needs a CRM module change (NOT made, KY to decide):** a link that was STARTED FROM THE CRM (its Connect wizard, or the CRM typing a code that Chat showed) can never be given write access: the module sets `access_in` to Look only for that direction (`bxl_set_access`, `bx_links_helper.php:1092`), so "Allow changes" in the CRM changes nothing and Chat gets "Look only" for ever. Links started from Chat (Connect in one click, or Chat typing a code the CRM shows) work. Until the module is fixed, pair from Xpace Chat; Chat's sentence now says so. Also noted for the CRM module: a lead can be inserted twice inside one request and still answer 200 (`_fallback_insert_lead`), no idempotency key exists for leads, and the CSRF cookie name is not prefixed with `cookie_prefix`.

Tests: 161 pass (136 before + 25 new in `src/crm/paired.test.ts`; the stand-in CRM refuses writes on a CRM-started link like the real module). Browser retest on a CRM 1.14.1 TEST rig: retest-0.3.0.md. Opus review: opus-review-0.3.0.md.

## 0.2.3: CRM detection, Test route, no company number asked (BUI-40, from the Tester's BUI-39 report)
Contract: BX-PAIRING-CONTRACT-v1.1. Nothing was removed. The lead link is NOT changed (KY decision pending).
1. **Chat can now start a link to the CRM and redeem a CRM code.** The CRM's key-less ping answers 401 `key_rejected` with the contract only in the `X-BX-Contract` header (no contract field in the body), so Chat took the CRM for another app and posted to routes that do not exist (403/404). Chat now also accepts the header, but only on a contract refusal (401 or 429 with a `code` in the JSON body). A header alone on a WAF 403, a 405, a 200 page, or a body naming another app is still not taken for the CRM (keeps the 0.2.1 review fix S2).
2. **Test against SiteOps and Calculator reads the right summary.** The read step called the old `/api/v1/summary`; it now calls `/api/connect/v1/summary` with the link key, so Test says "Working" instead of ending needs_attention.
3. **Chat no longer asks for a company number.** Starting or entering a code with no number held passes (v1.1 section 5: an empty id passes). The "Company number" box is gone from the Connect panel. Chat adopts the number from the first CRM or Calculator that has one; a CRM or Calculator number that differs from Chat's own is still refused (`wrong_company`). The API still accepts an optional `tenant_id`. **Opus review fix:** if Chat still holds no number when the CRM or Calculator later reports one, the next Test adopts it (so a later different number is caught). A Marketing or SiteOps number is never adopted.
4. **"The peer may still show this link"** is not a Chat message. It is shown by SiteOps and Calculator, so nothing changed here; those two apps need the fix.

Tests: 136 pass (124 before + 12 new; 17 of the connect tests fail on the 0.2.2 logic). The stand-in CRM in the tests now behaves like the real one (refusal body without a contract field), so the old bug is no longer hidden. Opus review: opus-review-0.2.3.md (verdict: ship as TEST). **Open, not changed (for KY):** (a) the CRM probe has no retry on the other path if a WAF strips the CRM's header; (b) a non-CRM app whose contract error body (401/403/423) is served at the CRM path would still read as the CRM, as in 0.2.1; both need a real-world trigger and are small follow-ups. Hands-on browser retest at 1280 and 390 wide: retest-0.2.3.md.

## 0.2.2: company-number fixes from the re-run (BUI-37, from the Tester's BUI-36 report)
Contract: BX-PAIRING-CONTRACT-v1.1 (section 5, "Shared company id"). Nothing was removed. The lead link is NOT changed (KY decision pending).
1. **Only the CRM and the Calculator decide the company number.** Chat used to compare company numbers with every app, so with the CRM linked, Marketing (or SiteOps) with a different number was refused with "different companies", both when Marketing started one-click and when a code shown in Chat was typed into Marketing. Now Marketing and SiteOps keep their number as their own number only, the company check in the Test passes for them, and Chat never takes their number as its own. A CRM or Calculator with a different number is still refused (409, nothing created).
2. **A fresh CRM with no company number can now link to a fresh Chat with no number** (one-click and typed code). Before, Chat answered "That code didn't work". If either side has no number there is nothing to compare, so it passes; the CRM learns its number from the first link, and Chat takes its number from the first CRM or Calculator link that has one.
3. **Opus review fix:** if the CRM or Calculator linked while it had no number, the Test's company step would never have caught a later different number. It now compares with Chat's own number once Chat has one.

Not changed (noted for KY): Chat still asks for a company number when IT starts or redeems a link and has none, even for Marketing/SiteOps (harmless, the number is not used for them); an install that adopted a Marketing/SiteOps number under 0.2.1 keeps it (TEST installs only, none known).

Tests: 124 pass (118 before + 6 new, the first 5 fail on 0.2.1 logic). Opus review: opus-review-0.2.2.md.

## 0.2.1: fixes from the side-by-side test (BUI-34, from the Tester's BUI-30 report)
Contract: BX-PAIRING-CONTRACT-v1.1. Nothing was removed. Still TEST only: not deployed, no live data.
1. **Wrong codes lock the address, not the code.** 5 wrong codes from one address within 10 minutes lock that address out of pairing for 10 minutes. The code is NOT burned: it stays valid until used, expired (10 min) or cancelled. During the lock the address gets the same "code_invalid" reply as any wrong code (even for the right code); other addresses are not affected. The count is kept in the database (table `pair_lock`), so a restart does not clear it. The 10-tries-a-minute limit (429 slow_down) is unchanged.
2. **The CRM is called at `/bx_integration_api/connect_v1/*`** (with `test_event`), and its one-click screen at `/admin/bx_integration_api/connect/start`. Chat finds out whether an address is the CRM by a key-less ping (a pair-1 reply at the CRM address), not by assuming; before that nothing secret is sent. Every other app is still called at `/api/connect/v1/*`. The CRM still calls Chat at `/api/connect/v1/*`.
3. **A bare 402 (or 423, or `{"paused":true}`) now shows the "paused" sentence** ("... is paused for this company (payment needed)."), on the reach, events and read steps, not "key_rejected".
4. **"Allow changes" text** now says access is set separately on each side: "This only changes what {name} may do in Xpace Chat. What Xpace Chat may do in {name} is set separately, in {name}." (English, Malay, Chinese). The Test's "level" step matched: the other app's level is recorded (`peer_access`) and a missing, "look" or "change" value all pass; only an unknown value is a mismatch. This goes slightly beyond the six listed items; it follows the same contract rule (section 6).
5. **Sign-in tokens are no longer stored raw.** The session table keeps a SHA-256 of the token; the cookie still holds the real token. People signed in under 0.2.0 stay signed in (their rows are hashed once at start-up). **Rollback caveat:** if you go back to 0.2.0 or older after running 0.2.1, everyone must sign in again.
6. **Chat to Perfex lead sync (the older, hand-made connector) could not be tried on the lab rig** (it has no Perfex REST module). It is now covered by a stand-in test: a small fake Perfex REST server that checks the `authtoken` header, answers `/api/staffs` and `/api/leads`, and accepts a new lead. The test connects by hand, runs Test (a wrong key shows key_rejected; the right key passes), pulls staff and leads in, pushes a new chat contact out as a lead, and checks the key is stored sealed. **This proves Chat's side of the adapter against the field names it expects. It does not prove the real Perfex REST module answers the same way: that needs a real Perfex.**
7. **Opus review fixes (all applied):** the pairing lock uses the real connection address; `X-Forwarded-For` is only believed when the call arrives from this machine or a private network (our own proxy), so a spoofed header from the internet cannot dodge or flood the lock; the lock table is capped at 5000 rows; the CRM is only recognised when its key-less reply is a pair-1 JSON reply (a header alone, or an HTML/other reply, is not enough); a bare `{"paused":true}` on the ping step now shows the paused sentence; the CRM's "Open Xpace CRM" link goes to `/admin/bx_integration_api/connect`; `resetStray` is kept (it now clears the address locks), so nothing was removed. **Behind a proxy on the same machine that sends no `X-Forwarded-For`, all callers share one address and one lock.** Set the header at the proxy.
Tests: 118 pass (103 before + 15 new). The Opus review is in this folder (opus-review-0.2.1.md).

## What is new in 0.2.0 (plain words)
- A new **Connect apps** page (menu: Apps; on a phone: Me > Connect apps). Admins only.
- Link Xpace Chat to another Xpace app (the CRM, Marketing, SiteOps, Calculator) **in one click**, or with a short code (K7QM-2XPD, works once, lasts 10 minutes). The CRM hosts the main set-up wizard; this page is the Chat side.
- Every link shows **Look only** (default) or **Look and change**. Allowing changes needs a second click and a warning. Lowering back to Look only is one click, from either side.
- Each link has **Test** (8 plain checks, one plain sentence if something is wrong), **Reset**, **Open the other app** and **Disconnect**. Disconnecting keeps all chats and customers.
- Apps that were disconnected stay listed for a while ("Disconnected by ...").
- Optional cards, each with **Set up later** (grey, not an error): Claude (coming soon), Perfex (paste address and key), WhatsApp (Connect with Facebook), Meta and Instagram (open Xpace Marketing). A finish list shows "2 things to set up later: WhatsApp, Instagram".
- Every link made, changed or removed is written to the Activity log. No key, code or secret is ever written there.
- When the CRM is connected through a link, the CRM leads (contract rule A). The old manual Perfex set-up still works exactly as before.

## Nothing removed
Every 0.1.x function is unchanged when no link exists. Tests: 103 pass (the earlier 61 plus 42 new).

## For the person installing
- New settings in code only: none required. For a lab test without https set `XC_CONNECT_ALLOW_HTTP_LOOPBACK=1` (127.0.0.1 only; never in production).
- If the other app really sits on a private network address, set `XC_CONNECT_ALLOW_PRIVATE=1`; by default Chat refuses to call private, loopback or link-local addresses.
- Link keys are shown once and only a hash is kept; keys Chat holds for calling the other app and the Meta/CRM secrets are stored encrypted. **Rollback caveat:** going back to 0.1.x cannot read the newly encrypted Meta/CRM values; re-enter them if you roll back.
- `dist/connect/stubpeer.js` and `connect.test.js` are a fake CRM used only by the tests. It is inert and not part of the product.

## Open points to confirm (assumptions)
1. The BX CRM lead API is not in the contract, so Chat reuses its Perfex adapter, pointed at the CRM link (key = the link key).
2. "Level" check: settled by contract v1.1 section 6. Access is independent per side; Chat records the other app's level and a missing value passes. (0.2.0 flagged "change" vs "look"; fixed in 0.2.1.)
3. "Share these updates" is stored and audited; Chat has no events to share yet.
4. The company number is taken from the first app that links. Typing it once is needed when Chat starts or redeems first.
5. Settled by KY (v1.1): 5 wrong codes from one address lock that address for 10 minutes; the code is not burned (0.2.1). The per-minute limits are still in memory per app copy.
9. When the CRM is paired, leads still go through the link key used as the Perfex `authtoken` (as in 0.2.0). The reviewer believes this may not work on a real Perfex; waiting for KY's decision. Not changed in 0.2.1.
6. HTTPS is judged from the proxy's forwarded headers (last entry only). The proxy must set X-Forwarded-Proto.
7. The real Facebook/Meta sign-in could not be tested without Meta access; tested with a stand-in sign-in window only.
8. Claude card shows "Coming soon" (no /mcp in Chat yet).

## Independent (Opus) review: what it found and what was done
Found 11 points; all fixed in this build: start link now needs a signed-in admin and shows the other app's address; forwarded-address spoofing no longer bypasses the limits or https rule; wrong tries no longer burn other people's codes; raising access no longer breaks the test; actions from other websites refused (origin check); private/loopback addresses refused; "removed by the other app" now shown; signed updates need an event id; a bad stored key can no longer block Disconnect; doubled web address parameters no longer crash; link keys on the older endpoints are rate-limited and the old bridge key is compared safely.

## BX pairing contract acceptance (section 12), checked on this build
1. One click both ways and typed code: pass (browser, desktop 1280 and phone 390, plus tests).
2. Code rules (single use, 10 min, 6th try, wrong company, same answer): pass (tests).
3. Key once / hash only / no key in log, audit, files: pass (tests; searched the data folder, logs, source and build for keys, codes and the admin password: none).
4. Look only default, write refused with a plain sentence, raise needs admin and second click, lower from either side: pass.
5. Each broken test step shows its exact sentence: pass in the browser (key, company, clock, signature, paused, unreachable).
6. Disconnect both ways, data intact, re-pair works, CRM-leads switches both ways: pass.
7. Cards: Set up later / Set up now / finish list: pass. Claude is "Coming soon" (not testable). Perfex paste form shown; WhatsApp tested with a stand-in sign-in only.
8. Old manual links and existing functions still work, audit shows each event: pass.
9. Opus review done; TEST zip to releases; not deployed.

## BX App Standard (parts touched)
One main action per screen: pass. Plain words EN/MS/ZH: pass (new ap_* texts in all three). Empty state with one button: pass. Phone width: pass (390 px, no sideways scroll). Standalone and integrable: pass. No function removed: pass.

---
# Xpace Chat 0.1.0 — release notes (1 Nov 2026)

Successor of WA Internal AI Agent (bx_agents) 1.6.0. Standalone Node app + thin Perfex module `xpace_chat` 1.7.0. Built from the approved UI/UX canvas (13 screens) and SPEC v1.

## What is in this build
- **WhatsApp Link (QR):** each salesperson links their phone like WhatsApp Web; no Meta account needed to read chats and get AI drafts. Human-paced sending; proactive messages only to people who wrote in first; daily cap per linked number.
- **WhatsApp Business API (Meta):** ported from 1.5.0 (Connect with Facebook, provider relay, paste key, own app), templates fetched from Meta, webhook with signature check, echoes from the phone app.
- **WeCom (企业微信) for internal staff:** official bot callback (encrypted), send to user/group, create project groups, 群机器人 fallback. Cross-company groups (China designers) to be confirmed in the pilot.
- **One inbox:** waiting / drafts ready / follow-ups; AI draft card (Send, Send later, Edit, Reject, Shorter · 中文 · Bahasa); 24-hour window pill; customer panel; take over / assign; project rooms merge the WhatsApp customer and the WeChat team in one window with a Reply-to switch.
- **Reply brain:** faithful port of 1.4.0 (fact-sheet-only prices, quick replies word for word, hand-over topics, never-promise, injection guard, holding reply, monthly AI budget, Try it). Engines: Claude (default claude-haiku-5-5) or OpenAI.
- **Follow-ups:** stage ladder (enquiry 1/3 d, quotation 3/7/14 d, measurement 2/7 d, handover 7/30 d), quiet hours, max per stage, stops on reply/STOP/closed; prepared for a person, never sent on its own.
- **Bulk send:** who (filters, paste list) → message (approved template) → when (on approval / date / spread over days); skip reasons shown; route = Meta for lists, slow send from a linked phone for small prior-inbound rounds; preparer never approves; batches with pauses; STOP removes for good.
- **Internal rooms:** team rooms read from WhatsApp groups / WeCom; AI spots tasks and customer notices; tasks close from chat; team brief 17:30; owner brief 08:00; whereabouts.
- **Own numbers (part-timers):** unchanged from 1.6.0: agree first, only company customers recorded, private Not sorted tray, Customer/Personal, erased after N days, Stop recording.
- **Roles:** same rights names as 1.6.0; SSO from the CRM; local login when standalone.
- **Languages:** EN / MS / ZH (714 texts carried from 1.6.0).
- **CRM:** Perfex module 1.7.0 = sidebar items (Inbox, Internal, Team, Connect) in an iframe with one sign-in, bridge API (staff, leads, notes, stage, tasks, projects), importer from 1.6.0 (repeat-safe).
- **Phone:** installable web app (Add to home screen); bottom bar Inbox · Follow-ups · Internal · Me.
- Tests: 61 (vitest) + PHP SSO vector test; independent safety review done (13 fixes applied, listed in the review log).

## Where every 1.6.0 function went (standard check 16)
| 1.6.0 | Xpace Chat |
|---|---|
| Get started wizard | Connect page (setup steps + Go live / Back to test mode) + Teach the AI |
| Connect WhatsApp (Meta) | Connect, tile 2 |
| WhatsApp settings (numbers, approvers, assignment, opt words, block list, cap, rates) | Settings › Basics / Advanced; numbers on Connect |
| Reply brain (AI) | Teach the AI (same 5 sections + Try it) |
| My chats / Team view / Take over | Inbox (same filters, badges); Team |
| Draft approvals inbox | Inbox drafts + Team › Needs your OK |
| Quick-add lead | Inbox › + (POST /quick-add) |
| Messages: My messages / Follow-ups / Send later / Marketing campaign | Settings › My messages; Follow-ups; Send later on every draft; Bulk send |
| Scheduled sends | Follow-ups › Scheduled by you |
| Spend (estimate) + CSV | Settings › Spend |
| Safe auto-replies, Pause ALL | Settings › Advanced (same rules, accuracy switch-off) |
| Not sorted tray, own-number agree/stop | Me › Your own number; Tray |
| Reports · Run history / All proposals | Settings › Activity log (audit); agent runs stay in bx_agents until the back-office agents move (phase 5) |
| Agent Inbox (Finance/Ops/Trade dispatch/Owner brief proposals) | **Not moved yet** — keep bx_agents 1.6.0 active for the back-office agents; Xpace Chat owns WhatsApp. Owner brief is reproduced in Xpace Chat. |

## BX App Standard, 16 checks (honest status)
1 Separate screens per role: pass (salesperson / manager / admin menus). 2 ≤5 menu items per role: pass on phone (4); desktop admin has 8 → group into "More" (next build). 3 One main action per screen: pass. 4 Plain words EN/MS/ZH: pass; technical words under Connect › IT help forms. 5 One-click setup: pass for WhatsApp Link (scan) and CRM (Enable); **partial** for Meta (one-click when the provider relay is set up by Xpace IT, otherwise paste) and WeCom (paste from WeCom admin). 6 Get started ≤5 steps on a phone: pass (6 steps shown as 5 + Go live; merge to 5 next build). 7 Save in place with ✓: pass. 8 Empty states with one button: pass. 9 Follow current habits: pass (quick replies verbatim, phone app kept). 10 Plan/limits from BX Account Hub: **not yet** (no billing inside; limits are settings). 11 Standalone + inside CRM with one sign-in: pass. 12 Integration contract events: **partial** (REST bridge; events next). 13 Multi-tenant: **not yet** — one company per install (one container per tenant for now). 14 Non-technical click-through: **pending** — needs a real linked phone; sandbox had no WhatsApp access. 15 Release notes + zip in releases/xpace-chat/: pass. 16 No function removed: pass (table above).

## Known limits in this build
- Not tested against a live WhatsApp/Meta/WeCom account (no internet from the build sandbox). First real test: install, scan one phone, send a test message in test mode.
- Admin desktop menu has 8 items; phone has 4.
- Price-flag drafts: 1.6.0 behaviour kept (salesperson confirms once). Setting `price_flag_needs_manager` switches to manager approval.
- Internal rooms from WhatsApp groups need the company number linked; WeCom external groups to confirm in pilot.

## Install (plain words)
See INSTALL.md: hosted (nothing to install) or `docker compose up -d` on your server; open the address, sign in with the admin password in `data/admin-password.txt`, Connect › scan. CRM: upload `xpace_chat-perfex-1.7.0.zip`, Activate, paste the Xpace Chat address, Generate secret, Import from 1.6.0, Open.
