You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "sunrioa (via GitHub)" <gi...@apache.org> on 2026/08/28 14:23:17 UTC
[PR] feat(desktop): add host-bound folder references to the composer [maka]
sunrioa opened a new pull request, #4097:
URL: https://github.com/apache/maka/pull/4097
## Summary
Fixes #3994.
Split the composer’s “Add files or directories” entry into “Add files” and “Reference folder”, with a native folder picker and removable folder-reference chips.
- Support up to four folder references per message, bound to the originating Runtime Host.
- Prepare a bounded, non-recursive directory listing when admitting a new message. File contents remain available through the existing filesystem tools on demand.
- Persist directory references and their prepared observations through send, reload, replay, and regeneration while preserving the user-authored message text.
- Keep the selected project, working directory, attachments, and sandbox permissions unchanged.
### Before

### After


## Review focus
Directory selection is a reference, not a recursive upload or permission grant. Listing uses the existing filesystem boundary; inaccessible directories are reported as requiring access or unavailable, rather than silently treated as empty.
Preparation is limited to 100 entries per directory, a shared 8 KiB serialized-entry budget, and a five-second timeout. Timeout, cancellation, foreign-host references, and unsupported external execution are handled without turning expected preparation failures into a Runtime Host drain.
The change spans the Desktop picker/composer, message contracts, Runtime Host admission, runtime directory preparation, and persistence/rendering. Runtime Host compatibility advances from 56 to 57, so the Desktop and Runtime Host must be updated together.
Supporting test changes close SQLite fixture stores before cleanup and handle platform-specific symlink and `/proc/self/fd` assumptions. Generated source/test inventories are updated; local verification notes and build artifacts are not included.
## Verification
Verified against head `f6f9c04fbdd73640038f178831cd7e52df3c5788`.
### macOS
- Build, lint, format, typecheck, and Desktop/UI knip checks passed.
- ASF header and generated inventory checks passed.
- Runtime suite: 3,067 passed, 13 skipped, no failures.
- Runtime Host suite: 1,325 passed, 9 skipped, no failures.
- Focused Core, Desktop, and UI checks: 58 passed.
- Directory-reference Desktop E2E: 10/10 passed with `--repeat-each=10`.
- `check:release`: passed, including 110 tests.
- Added regression cases were verified failing before the corresponding fixes and passing afterward.
- Manual verification covered folder selection, directory-reference display, and reading referenced files without changing the working directory.
### Windows
Contributor-run validation of the same head:
- Build and focused regression checks passed: 184 passed, three expected platform skips, no failures.
- `smoke:windows:dist`, Desktop packaging, and `verify:windows-x64` passed.
- Packaged checks covered AppContainer execution, cancellation recovery, parent-process exit cleanup, 64-way concurrency, the adversarial matrix, node-pty, and renderer checks.
- The new packaged build launched successfully.
- Earlier manual acceptance covered Chinese/space-containing paths and adding/removing directory-reference chips.
### Validation limitations
- The earlier full Desktop E2E run had 77 passes, one skip, and one sidebar-resize failure. The same sidebar test also failed on the unmodified baseline. The full matrix was not rerun after the final follow-up; the affected directory-reference E2E was rerun successfully.
- The top-level Windows packaging command previously encountered a standalone-launcher check blocked by an unavailable WSL `/bin/bash`. Desktop workspace packaging and final artifact verification passed; this does not establish that the top-level packaging command passes in that environment.
## AI use
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: OpenAI Codex assisted with source inspection, implementation, regression tests, local verification, code review, and drafting this PR. I have reviewed the changes and take responsibility for this contribution.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #4097:
URL: https://github.com/apache/maka/pull/4097
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5464235941
Addressed in `82d148ad31f71ca752b0688dc70c27c6aedaf396`.
I narrowed the implementation to the path-only design suggested in the review:
- directory references now persist only `{ hostId, path }`;
- the eager directory listing and its timeout, cancellation, frozen-preview, and replay machinery were removed;
- directory contents are inspected on demand through the existing Glob/Read tools and permission flow;
- draft handoff, queueing, send, reload, replay, and regeneration continue to preserve the Host-bound reference.
The focused macOS suites and E2E stability runs pass. Full Windows validation passed on the pre-merge feature head, and all required GitHub Actions checks are green on the final head.
The PR description has also been updated to reflect the reduced scope and current verification results.
<details>
<summary>简体中文</summary>
已在 `82d148ad31f71ca752b0688dc70c27c6aedaf396` 中按照审查建议完成调整。
实现现已收窄为仅保留路径的设计:
- 目录引用只持久化 `{ hostId, path }`;
- 删除了预先读取目录以及相关的超时、取消、冻结预览和重放逻辑;
- Agent 通过现有的 Glob/Read 工具和权限流程按需检查目录内容;
- 草稿交接、排队、发送、重载、重放和重新生成仍会保留绑定 Host 的目录引用。
macOS 定向测试和 E2E 稳定性复跑均已通过。合并前的功能提交已完成完整 Windows 验证,最终提交上的全部必需 GitHub Actions 检查也已通过。
PR 描述也已更新,以反映收窄后的实现范围和最新验证结果。
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5478961956
Synced this branch with current `main` and resolved the overlapping composer/attachment changes in `41da9e83c`.
The PR is conflict-free. Exact-head local verification passed: clean build and typecheck, lint/format/ASF and renderer-architecture checks, focused directory-reference and attachment coverage, the directory-reference Electron E2E, full Runtime (3096/3096), Runtime Host (1465/1465), Desktop (1759/1759) suites, and release checks (141/141). GitHub Actions is now running on the new head.
@Astro-Han ready for merge once the hosted checks finish. Thanks!
<details>
<summary>简体中文</summary>
已在 `41da9e83c` 将该分支同步到当前 `main`,并解决 Composer/附件相关的重叠修改。
PR 当前已无冲突。精确提交的本地验证已通过:干净构建和类型检查、lint/format/ASF/渲染器架构检查、目录引用与附件定向覆盖、目录引用 Electron E2E、完整 Runtime(3096/3096)、Runtime Host(1465/1465)、Desktop(1759/1759)测试,以及 release 检查(141/141)。GitHub Actions 正在对新提交运行。
@Astro-Han 远端检查完成后即可合并,感谢!
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #4097:
URL: https://github.com/apache/maka/pull/4097#discussion_r3891016319
##########
packages/ui/src/__tests__/conversation-copy.test.ts:
##########
@@ -25,6 +25,34 @@ test('labels the Chinese default thinking level as default', () => {
assert.equal(getConversationCopy('zh').model.defaultLevel, '默认');
});
+test('expanded-context edit guidance coexists with current retry and recovery copy', () => {
Review Comment:
Thanks — [P3] Could we keep this test scoped to the changed expanded-context copy? The retry and `safeResume` assertions are unrelated pre-existing behavior, so bundling them here adds maintenance without protecting folder references. I’d remove those assertions, or this whole test if the exact expanded-context wording is not a contract. Please push back if this grouping protects a known regression.
##########
apps/desktop/src/renderer/use-composer-attachments.ts:
##########
@@ -228,45 +259,135 @@ export function useComposerAttachments(options: {
}
}
+ async function pickDirectory(): Promise<void> {
+ const owner = optionsRef.current;
+ if (!owner.directoryHostId || !owner.service.pickDirectory) return;
+ const ownerKey = `${owner.draftKey}:${owner.directoryHostId}`;
+ try {
+ const result = await owner.service.pickDirectory();
+ if (!result.ok) return;
+ const current = optionsRef.current;
+ if (
+ current.draftKey !== owner.draftKey
+ || current.directoryHostId !== owner.directoryHostId
+ ) return;
+ if (result.reference.hostId !== owner.directoryHostId) {
+ throw new Error('Directory references require the local Host.');
+ }
+ updateDirectories((all) => {
+ const previous = all[ownerKey] ?? [];
+ if (
+ previous.length >= DIRECTORY_REFERENCE_MAX_COUNT
+ || previous.some((entry) =>
+ entry.path === result.reference.path && entry.hostId === result.reference.hostId
+ )
+ ) return all;
+ return { ...all, [ownerKey]: [...previous, result.reference] };
+ });
+ } catch (error) {
+ owner.toastApi.error(
+ copy.attachmentFailedTitle,
+ localizedShellErrorMessage(error, copy.tryAgain, uiLocale),
+ );
+ }
+ }
+
async function attachFilePaths(files: File[]): Promise<void> {
if (files.length === 0) return;
const ownerKey = options.draftKey;
const staged = files.map(fileToPending);
- setPendingByKey((map) => appendPending(map, ownerKey, staged));
+ updateAttachments((map) => appendPending(map, ownerKey, staged));
for (const item of staged) stagedKeysRef.current.add(item.stagingKey);
void loadPreviewsSequentially(staged);
}
function restoreAttachments(ownerKey: string, attachments: readonly AttachmentRef[]): void {
if (attachments.length === 0) return;
const staged = attachments.map(retainedToPending);
- setPendingByKey((map) => appendPending(map, ownerKey, staged));
+ updateAttachments((map) => appendPending(map, ownerKey, staged));
for (const item of staged) stagedKeysRef.current.add(item.stagingKey);
}
function removeAttachment(index: number): void {
const ownerKey = options.draftKey;
- setPendingByKey((map) => removePending(map, ownerKey, index));
+ updateAttachments((map) => removePending(map, ownerKey, index));
+ }
+
+ function removeDirectory(index: number): void {
+ updateDirectories((all) => {
+ const previous = all[directoryDraftKey] ?? [];
+ if (index < 0 || index >= previous.length) return all;
+ return {
+ ...all,
+ [directoryDraftKey]: previous.filter((_, entryIndex) => entryIndex !== index),
+ };
+ });
+ }
+
+ function clearSubmittedContext(submitted?: readonly PendingAttachment[]): void {
+ setPendingState((current) => {
+ const attachments = submitted
+ ? removePendingItems(
+ current.attachments,
+ options.draftKey,
+ submitted,
+ pendingAttachmentSourceKey,
+ )
+ : current.attachments;
+ const previous = current.directories[directoryDraftKey] ?? [];
+ const next = previous.filter((reference) => !pendingDirectories.includes(reference));
+ return {
+ attachments,
+ directories: next.length === previous.length
+ ? current.directories
+ : { ...current.directories, [directoryDraftKey]: next },
+ };
+ });
}
function clearSubmittedAttachments(submitted: readonly PendingAttachment[]): void {
- const ownerKey = options.draftKey;
- setPendingByKey((map) =>
- removePendingItems(map, ownerKey, submitted, pendingAttachmentSourceKey),
+ updateAttachments((current) =>
+ removePendingItems(current, options.draftKey, submitted, pendingAttachmentSourceKey),
);
}
+ function clearSubmittedDirectories(submitted: readonly DirectoryReference[]): void {
+ updateDirectories((current) => {
+ const previous = current[directoryDraftKey] ?? [];
+ const next = previous.filter((reference) => !submitted.includes(reference));
+ return next.length === previous.length
+ ? current
+ : { ...current, [directoryDraftKey]: next };
+ });
+ }
+
function clearAllAttachments(): void {
- setPendingByKey({});
+ updateAttachments(() => ({}));
}
return {
pendingAttachments,
+ pendingDirectories,
+ submittableAttachments: pendingAttachments.length ? pendingAttachments : undefined,
+ hasPendingContext: pendingAttachments.length > 0 || pendingDirectories.length > 0,
+ directoryOptions: pendingDirectories.length > 0
+ ? { directoryReferences: pendingDirectories }
+ : {},
+ directoryComposerProps: {
+ pendingDirectories,
+ onRemoveDirectory: removeDirectory,
+ onPickDirectory: pendingDirectories.length < DIRECTORY_REFERENCE_MAX_COUNT
+ ? pickDirectory
+ : undefined,
+ },
pickAttachments,
attachFilePaths,
restoreAttachments,
removeAttachment,
+ removeDirectory,
+ clearSubmittedContext,
clearSubmittedAttachments,
+ clearSubmittedDirectories,
Review Comment:
Thanks — [P3] Could we avoid returning `removeDirectory` and `clearSubmittedDirectories` solely for tests? Production consumes removal through `directoryComposerProps` and clearing through `clearSubmittedContext`; exposing the lower-level operations expands the hook contract only to support the fixture. Rewriting the test through the production entry points would let these return values disappear and better guard real behavior. Please push back if there is a production consumer I missed.
##########
packages/runtime/src/__tests__/directory-reference-model-context.test.ts:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { formatTextWithInlineRefs } from '../model-history.js';
+
+const reference = { hostId: 'host-a', path: '/workspace/source' };
+
+test('formats only the Host-bound directory reference for the current model turn', () => {
Review Comment:
Thanks — [P3] This exact full-prompt assertion seems redundant with the backend integration that proves current and historical references reach the model, while the next test already guards escaping and excluded fields. Could we remove this test and keep the behavior-level integration plus the security invariant? That would avoid CI failures on harmless wording changes. Please push back if the exact prose is intended as a stable contract.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on code in PR #4097:
URL: https://github.com/apache/maka/pull/4097#discussion_r3891406276
##########
packages/runtime/src/__tests__/directory-reference-model-context.test.ts:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { formatTextWithInlineRefs } from '../model-history.js';
+
+const reference = { hostId: 'host-a', path: '/workspace/source' };
+
+test('formats only the Host-bound directory reference for the current model turn', () => {
Review Comment:
Agreed. Addressed in `06c799135`.
I removed the exact full-prompt assertion. The remaining coverage keeps the behavior-level backend integration and the security invariant for escaping untrusted paths and excluding preview-only fields.
##########
packages/ui/src/__tests__/conversation-copy.test.ts:
##########
@@ -25,6 +25,34 @@ test('labels the Chinese default thinking level as default', () => {
assert.equal(getConversationCopy('zh').model.defaultLevel, '默认');
});
+test('expanded-context edit guidance coexists with current retry and recovery copy', () => {
Review Comment:
Agreed. Addressed in `06c799135`.
I removed the unrelated retry and `safeResume` assertions. The retained test is scoped only to the folder-reference edit-and-resend guidance introduced by this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5479740588
Somehow the CI did not start while it conflict again... Would you mind if I help to rebase and push to the branch? I will only rebase to the latest and merge once the conflict is solve and ci passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5478668975
The main moved again, Could you do another rebase and ping me when you done? I can merge the PR quickly to avoid another round of rebase. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5486681407
Since the branch remained unchanged while `main` advanced again, I confirmed there was no concurrent remote update, completed the two syncs locally, and pushed the tested merge result myself. The final state after both syncs is consolidated below. Both updates were regular pushes, not force pushes.
The branch is now at exact head `11dd3d6a438a290edb2318195c8e9149bd01dc3a` and includes `main` through `8b0e43f7cd71f2293e6a1e5b5cbc9db81ff5c1d0`. The PR is conflict-free.
Exact-head local verification completed:
- clean build, typecheck, lint, formatting, ASF headers, Windows inventory, Astryx inventory, and renderer architecture checks passed;
- the protocol compatibility guard passed with epoch `83 -> 84`;
- the full Core suite passed;
- the full affected workspace suites passed: Runtime `3116/3116`, Storage `1080/1080`, Runtime Host `1495/1495`, UI `281/281`, and Desktop `1792/1792` (platform-specific skips excluded from these pass counts);
- the directory-reference and adjacent WorkHub, parent-deletion, and sidebar Electron E2E set passed `9/9`;
- the directory-reference Electron E2E stability run passed `10/10`;
- release checks passed `153/153`.
For completeness, the only non-green local E2E result was the timing-sensitive `deleting the session while a toggle is pending settles clean` case. I reproduced the same failure at the same assertion in a separate clean worktree on exact current `main` (`8b0e43f7cd71f2293e6a1e5b5cbc9db81ff5c1d0`), so it is not introduced by this PR.
All required hosted workflows on the updated exact head are green: CI, Windows recovery, and Release Windows check.
@Astro-Han the branch is current, conflict-free, and green. It is ready to merge. Thanks!
<details>
<summary>简体中文</summary>
由于分支仍未发生变化,而 `main` 又再次前进,我先确认远端没有并行更新,随后在本地完成两次同步,并自行推送经过测试的合并结果。以下是两次同步后的最终状态汇总。两次更新均为普通推送,没有使用强制推送。
分支当前的精确提交为 `11dd3d6a438a290edb2318195c8e9149bd01dc3a`,其中已包含截至 `8b0e43f7cd71f2293e6a1e5b5cbc9db81ff5c1d0` 的 `main`。PR 当前没有冲突。
精确提交的本地验证已经完成:
- 干净构建、类型检查、lint、格式检查、ASF 许可证头、Windows 清单、Astryx 清单和渲染器架构检查均通过;
- 协议兼容性检查通过,epoch 从 `83` 提升到 `84`;
- Core 全量测试通过;
- 受影响工作区的全量测试均通过:Runtime `3116/3116`、Storage `1080/1080`、Runtime Host `1495/1495`、UI `281/281`、Desktop `1792/1792`(通过数不包含各平台专属跳过项);
- 目录引用及相邻的 WorkHub、父会话删除和侧边栏 Electron E2E 共 `9/9` 通过;
- 目录引用 Electron E2E 稳定性复跑 `10/10` 通过;
- release 检查 `153/153` 通过。
补充说明:唯一未通过的本地 E2E 是对时序敏感的 `deleting the session while a toggle is pending settles clean`。我在一个独立的干净 worktree 中,基于当前精确 `main`(`8b0e43f7cd71f2293e6a1e5b5cbc9db81ff5c1d0`)复现了同一断言位置的相同失败,因此它不是由本 PR 引入的。
更新后精确提交上的全部必需远端工作流均已通过:CI、Windows recovery 和 Release Windows check。
@Astro-Han 分支目前已同步、无冲突且检查全绿,可以合并。感谢!
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on PR #4097:
URL: https://github.com/apache/maka/pull/4097#issuecomment-5479858883
Yes, please go ahead. I synced the branch to 802c82734 and pushed d49ededf4; exact-head local checks passed, but main has moved again. You may rebase the branch to the latest main, push it, and merge once CI passes. I’ll avoid modifying the branch in the meantime. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] feat(desktop): add host-bound folder references to the composer [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on code in PR #4097:
URL: https://github.com/apache/maka/pull/4097#discussion_r3891405624
##########
apps/desktop/src/renderer/use-composer-attachments.ts:
##########
@@ -228,45 +259,135 @@ export function useComposerAttachments(options: {
}
}
+ async function pickDirectory(): Promise<void> {
+ const owner = optionsRef.current;
+ if (!owner.directoryHostId || !owner.service.pickDirectory) return;
+ const ownerKey = `${owner.draftKey}:${owner.directoryHostId}`;
+ try {
+ const result = await owner.service.pickDirectory();
+ if (!result.ok) return;
+ const current = optionsRef.current;
+ if (
+ current.draftKey !== owner.draftKey
+ || current.directoryHostId !== owner.directoryHostId
+ ) return;
+ if (result.reference.hostId !== owner.directoryHostId) {
+ throw new Error('Directory references require the local Host.');
+ }
+ updateDirectories((all) => {
+ const previous = all[ownerKey] ?? [];
+ if (
+ previous.length >= DIRECTORY_REFERENCE_MAX_COUNT
+ || previous.some((entry) =>
+ entry.path === result.reference.path && entry.hostId === result.reference.hostId
+ )
+ ) return all;
+ return { ...all, [ownerKey]: [...previous, result.reference] };
+ });
+ } catch (error) {
+ owner.toastApi.error(
+ copy.attachmentFailedTitle,
+ localizedShellErrorMessage(error, copy.tryAgain, uiLocale),
+ );
+ }
+ }
+
async function attachFilePaths(files: File[]): Promise<void> {
if (files.length === 0) return;
const ownerKey = options.draftKey;
const staged = files.map(fileToPending);
- setPendingByKey((map) => appendPending(map, ownerKey, staged));
+ updateAttachments((map) => appendPending(map, ownerKey, staged));
for (const item of staged) stagedKeysRef.current.add(item.stagingKey);
void loadPreviewsSequentially(staged);
}
function restoreAttachments(ownerKey: string, attachments: readonly AttachmentRef[]): void {
if (attachments.length === 0) return;
const staged = attachments.map(retainedToPending);
- setPendingByKey((map) => appendPending(map, ownerKey, staged));
+ updateAttachments((map) => appendPending(map, ownerKey, staged));
for (const item of staged) stagedKeysRef.current.add(item.stagingKey);
}
function removeAttachment(index: number): void {
const ownerKey = options.draftKey;
- setPendingByKey((map) => removePending(map, ownerKey, index));
+ updateAttachments((map) => removePending(map, ownerKey, index));
+ }
+
+ function removeDirectory(index: number): void {
+ updateDirectories((all) => {
+ const previous = all[directoryDraftKey] ?? [];
+ if (index < 0 || index >= previous.length) return all;
+ return {
+ ...all,
+ [directoryDraftKey]: previous.filter((_, entryIndex) => entryIndex !== index),
+ };
+ });
+ }
+
+ function clearSubmittedContext(submitted?: readonly PendingAttachment[]): void {
+ setPendingState((current) => {
+ const attachments = submitted
+ ? removePendingItems(
+ current.attachments,
+ options.draftKey,
+ submitted,
+ pendingAttachmentSourceKey,
+ )
+ : current.attachments;
+ const previous = current.directories[directoryDraftKey] ?? [];
+ const next = previous.filter((reference) => !pendingDirectories.includes(reference));
+ return {
+ attachments,
+ directories: next.length === previous.length
+ ? current.directories
+ : { ...current.directories, [directoryDraftKey]: next },
+ };
+ });
}
function clearSubmittedAttachments(submitted: readonly PendingAttachment[]): void {
- const ownerKey = options.draftKey;
- setPendingByKey((map) =>
- removePendingItems(map, ownerKey, submitted, pendingAttachmentSourceKey),
+ updateAttachments((current) =>
+ removePendingItems(current, options.draftKey, submitted, pendingAttachmentSourceKey),
);
}
+ function clearSubmittedDirectories(submitted: readonly DirectoryReference[]): void {
+ updateDirectories((current) => {
+ const previous = current[directoryDraftKey] ?? [];
+ const next = previous.filter((reference) => !submitted.includes(reference));
+ return next.length === previous.length
+ ? current
+ : { ...current, [directoryDraftKey]: next };
+ });
+ }
+
function clearAllAttachments(): void {
- setPendingByKey({});
+ updateAttachments(() => ({}));
}
return {
pendingAttachments,
+ pendingDirectories,
+ submittableAttachments: pendingAttachments.length ? pendingAttachments : undefined,
+ hasPendingContext: pendingAttachments.length > 0 || pendingDirectories.length > 0,
+ directoryOptions: pendingDirectories.length > 0
+ ? { directoryReferences: pendingDirectories }
+ : {},
+ directoryComposerProps: {
+ pendingDirectories,
+ onRemoveDirectory: removeDirectory,
+ onPickDirectory: pendingDirectories.length < DIRECTORY_REFERENCE_MAX_COUNT
+ ? pickDirectory
+ : undefined,
+ },
pickAttachments,
attachFilePaths,
restoreAttachments,
removeAttachment,
+ removeDirectory,
+ clearSubmittedContext,
clearSubmittedAttachments,
+ clearSubmittedDirectories,
Review Comment:
Agreed. Addressed in `06c799135`.
`removeDirectory` and `clearSubmittedDirectories` are no longer exposed from the hook. The directory tests now exercise the production entry points through `directoryComposerProps.onRemoveDirectory` and `clearSubmittedContext`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org